Notice
Recent Posts
Recent Comments
Link
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter02 : 기본자료형 본문

WEB.JS/01.BASIC_JS

chapter02 : 기본자료형

GAWON 2023. 5. 19. 09:17
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	/*
		기본 자료형 (소문자로 적어야함)
		1. 숫자 		number
		2. 문자열		string
		3. 논리형		boolean
		4. 널		null		(ex.숫자인지 문자인지는 앎/값을 모름)
		5. 언디파인드	undefined	(ex.숫자인지문자인지 모름)

		변수 (variable)
		1. 변수 선언시 자료형을 명시하지 않는다.
		2. 저장되는 값에 의해서 자료형이 결정된다.
		3. 선언 방법
			var 변수명;
		4. 변수명은 문자+숫자+특수문자(_, $)를 조합 할 수 있다.
		5. 첫 글자는 숫자일 수 없다.
		6. 공백 문자는 사용할 수 없다.
		7. 선언 하지 않은 변수도 사용할 수 있다.
	*/

	var a = 10;		// 변수 선언

	document.write(a);				// 값 : undefined
	document.write(typeof(a));		// 자료형 : undefined
	document.write("<br/>");

	/*
		변수의 초기화
		1. 객체 : null
		2. 숫자 : 0
		3. 문자열 : null
		4. 논리형 : false
	*/

	a = null;
	document.write(a);				// 값 : null
	document.write(typeof(a));		// 자료형 : object(객체)
	document.write("<br/>");

	/*
		문자열은 쌍따옴표("")와 홑따옴표('')를 모두 사용할 수 있다.
		문자는 별도로 존재하지 않는 자료형이다.(자바의 char 형)
	*/

	document.write("Hello javascript<br>");
	document.write('Hello javascript<br>');

	document.write("Hello 'javascript'<br>");
	document.write('Hello "javascript"<br>');




</script>
</head>
<body>

</body>
</html>

'WEB.JS > 01.BASIC_JS' 카테고리의 다른 글

chapter06 : es5_es6  (0) 2023.05.19
chapter05 : 대화상자  (0) 2023.05.19
chapter04 : 연산자  (0) 2023.05.19
chapter03 : 형변환  (0) 2023.05.19
chapter01 : basic_js  (0) 2023.05.19