2. 자바스크립트 객체
2.1 자바스크립트의 객체
2.1.1 내장 객체 : document, window, screen, browser 등
Date : 날짜와 시간 작업
Number : 수치형 데이터
String : 문자열 관련
Math : 수학 연산
Array : 배열
2.2.2 사용자 정의 객체
- 객체 상수로부터 객체 생성
var myCar = {
model: "520d",
speed: 60,
color: "red",
break: function() { this.speed -= 10; }
accel: function() { this.speed += 10; }
};
myCar.color = "yellow";
myCar.break();
- 생성자 함수를 이용한 객체 생성
function Car(model, speed, color) {
this.model = model;
this.speed = speed;
this.color = color;
this.break = function() {
this.speed -= speed;
}
this.accel = function() {
this.speed += speed;
}
}
var myCar = new Car("520d", 60, "white");
myCar.color = "yellow";
myCar.break();
2.2 실습예제
2.2.1 date1.html
2.2.2 date2.html
2.2.3 date3.html
2.2.4 date4.html
2.2.5 number1.html
2.2.6 number2.html
2.2.7 match.html
2.2.8 math1.html
2.2.9 math2.html
2.2.10 math3.html
2.2.11 array1.html
2.2.12 array2.html (요일 표시)
2.2.13 sort.html
2.2.14 try.html
2.2.15 screen.html
2.2.16 custom_type.html (사용자 정의 자료형)
2.2.17 calendar.html