Javascript 기본 튜...LOGIN

Javascript 기본 튜토리얼에 대한 참고 사항

댓글의 목적은 코드의 가독성을 높이고 귀하가 작성한 JavaScript 코드를 자신과 다른 사람들이 읽고 이해하도록 돕는 것입니다. 댓글의 내용은 웹페이지에 표시되지 않습니다. 주석은 한 줄 주석과 여러 줄 주석의 두 가지 유형으로 나눌 수 있습니다.

댓글 내용은 일반적으로 가독성을 높이기 위해 설명이 필요한 설명의 끝이나 주변에 배치됩니다.

한 줄 코멘트: //

다음 예를 참조하세요:

<!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>

우리는 하나의 출력 hello에만 코멘트를 달았고, 나중에 이 문장을 쓰기 위한 코멘트가 있습니다. 우리가 실행할 때 페이지에 표시되지는 않지만 다른 사람들이 소스 코드를 볼 때 이해하기가 더 쉽다는 의미입니다.


여러 줄 주석: /*댓글 내용 */

아래 예를 살펴보겠습니다. 처음 두 줄을 주석 처리하여

<!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>

참고: 위의 경우와 마찬가지로 필요할 때 처음 두 줄을 주석 처리하려면 2개의 문장을 작성할 때 단축키 ctrl + 물음표 키를 사용할 수도 있습니다. 전제는 주석을 달고 싶은 내용을 먼저 선택해야 한다는 것입니다

다음 섹션
<!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>
코스웨어