Notes on Javasc...LOGIN

Notes on Javascript Basics Tutorial

The purpose of comments is to improve the readability of the code and help yourself and others read and understand the JavaScript code you write. The content of the comments will not be displayed on the web page. Comments can be divided into two types: single-line comments and multi-line comments.

In order to facilitate reading, the comment content is generally placed at the end of or around the statement that needs to be explained.

Single-line comment: //

Please see the following example:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>javascript</title>
</head>
<body>
	<script type="text/javascript">
		//document.write("HELLO    ");
		document.write("WORLD    ");        //输出world
		document.write("php中文网    ");
		document.write("php.cn   ");
		document.write("世界你好");
	</script>
</body>
</html>

We only commented one output hello, and we have a comment afterwards to write this sentence It means that it will not be displayed on the page when we run it, but it will be easier for others to understand when they look at your source code


Multi-line comments: /*Comment content */

Let’s look at an example below, so that we can comment out the first two lines so that they will not be executed

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>javascript</title>
</head>
<body>
	<script type="text/javascript">
		/*document.write("HELLO    ");
		document.write("WORLD    ");
		*/
		document.write("php中文网    ");
		document.write("php.cn   ");
		document.write("世界你好");
	</script>
</body>
</html>

Note: As in the above case, when we need to comment out the previous When writing 2 sentences, you can also use the shortcut key ctrl+question mark key. The premise is that the content we want to comment must be selected first

Next Section
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>javascript</title> </head> <body> <script type="text/javascript"> //document.write("HELLO "); document.write("WORLD "); document.write("php中文网 "); document.write("php.cn "); document.write("世界你好"); </script> </body> </html>
submitReset Code
ChapterCourseware