데이터, 값, Data, Value
객체(Object)
- 속성(property)과 함수(method)로 구성되어 있다.
- 객체의 속성과 메소드는 .로 접근한다.
- 객체.속성
- 객체.메소드()
document 객체 : HTML 문서를 가리키는 객체
document.write() : 본문(<body>)에 출력
1. 숫자형
document.write(123); //정수
document.write(-123);
document.write(1.2); //실수
document.write(-3.4);
출력값 : 123
-123
1.2
-3.4
2. 문자형
-> 반드시 ' 또는 " 기호로 감싼다.
document.write("KOREA");
document.write("SEOUL");
document.write("대한민국");
document.write("서울특별시");
출력값 : KOREA
SEOUL
대한민국
서울특별시
에러
-> 크롬브라우저에서 F12를 이용해서 에러메세지 분석 후 수정
3. 논리형 (boolean)
-> 맞다(참 true), 틀리다(거짓 false)
document.write(true);
document.write(false);
document.write("true");
document.write("false");
document.write("1004");
출력값 : true
faluse
true
false
1004
'JavaScript' 카테고리의 다른 글
| [JS] 연산자 (0) | 2024.06.01 |
|---|---|
| [JS] document (0) | 2024.06.01 |
| [JS] 변수 (0) | 2024.06.01 |
| [JS] 출력 (0) | 2024.06.01 |
| [JS] 기본문법 (0) | 2024.06.01 |