before the start
If you have never touched JS. Go to the following website and experience it for 5 minutes:
Getting Started
browser based
JS is usually used in combination with HTML and CSS.
- write hellojs.html
Use Notepad to create a new one hellojs.html
with the following content:
<!DOCTYPE html>
<html>
<body>
<script>
alert("hello js");
</script>
</body>
</html>
- Effect view
Open this file directly with your browser.
You should see a pop-up box directly in the browser with the content "hello js".
Based on Node.js
For the grammar explanation of js, it is awkward to explain it together with html.
It is to use Node.js for code demonstration.
Node.js installation & usage
Baidu by yourself.
Or refer to:
- write
js-01-hello.js
Written in any editor, the content is as follows:
console.log("hello js");
- run
$ node js-01-hello.js
hello js