javascrip basic grammar
One, js annotation
Multi-line comments, the content in the comments will not be executed, but can be viewed in the source code.
To develop a good comment habit, you can also adjust the code through comments
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="text/javascript">
/*
js注释多行注释
*/
//js单行注释
</script>
</head>
<body>
</body>
</html>
Two, js is strictly case sensitive
Demo code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="text/javascript">
//document.write是像body里面写入内容
document.write('你好帅哥!')
document.write('你好美女!')
Document.write('你好哥哥')
</script>
</head>
<body>
</body>
</html>
Webpage effect: The
result shows that the third code is not executed! This is js is strictly case sensitive
Every statement in js ends with a semicolon (;)
The function of (;) is to tell the browser that over, this sentence is over.
If you don’t write a semicolon, the browser will automatically add it, but it will consume a certain amount of system resources, which will affect the performance of the browser. It is also possible that the system will add an error and cause your code to be wrong. Therefore, during development, a sentence must end manually. Add a semicolon.