WEB Archive

[HTML] Javascript - 변수 선언 및 초기화 실습

universedevelope 2024. 8. 21. 14:27
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	num1 = 10;									// 변수 num1에 10대입
	document.write("num1=");					// 문자열 출력
	document.write(num1);						// 변수 출력
	
	num1=100;									// 변수 num1 에 100 대입
	//document.write("\n num1="); 				// 문자열 출력, \n → 이거 개행 안됨~!!! ★check
	document.write("<br>num1=");				// 문자열 출력
	document.write(num1);						// 변수 출력
	
	num1="2022년 4월을 시작하는 어느 날...";	// 변수 num1 에 문자열 대입
	document.write("<br>num1=");
	document.write(num1);
	
	num2=200;			// 변수 num2 구성
	
	num1=num2;			// num1 에 num2  대입
	document.write("<br>num1="); // num1 출력
	document.write(num1);
	
</script>
</head>
<body>

</body>
</html>

변수를 계속 초기화 해주면 출력 위치에 따라 어떻게 출력되는지 확인해보는 실습이었습니다..

논리상 결과는 뻔하겠지요~???

728x90