|
| 1 | +## Running JavaScript: |
| 2 | + |
| 3 | +- We can run JS on the browser's console by which we will have access to the page we are on. |
| 4 | + |
| 5 | +- Also we can run it in a `script` tag: |
| 6 | + |
| 7 | +```javascript |
| 8 | +<script>console.log('Heyyy');</script> |
| 9 | +``` |
| 10 | + |
| 11 | +Always try to have your `script` tag before the closing `body` tag, because we can access the HTML elements written above the `script` tag as they are above the JS. |
| 12 | + |
| 13 | +- Also, we can run JS in another file using `script` tag with `src` attribute: |
| 14 | + |
| 15 | +```javascript |
| 16 | +<script src="relative path to js file"></script> |
| 17 | +``` |
| 18 | + |
| 19 | +- Also we can run it via Node.js - instead of running in the context of a website we run it in an actual machine. In console, run: `node file.js` |
0 commit comments