속성 = 현재상태
메소드 = 액션
let arr = [1,2,3,4,5]
let arr1 = new Array(1,2,3,4,5); // [1, 2, 3, 4, 5]
// 우리가 배열을 정의하는 것은 Array의 인스턴스를 만들어내는 것과 동일함
function Student(name, score, hobby) {
this.name = name;
this.score = score;
this.hobby = hobby;
}
Student.prototype.study = function() {
console.log(this.name + '가 JS를 공부하고있습니다')
}
let student1 = new Student('heaeun', 100, 'lol');
student1.name // "heaeun"
student1.study() // heaeun가 JS를 공부하고있습니다
< 용어 설명 >
1. prototype : 모델의 청사진을 만들 때 쓰는 원형 객체(original form)입니다.
2. constructor : 인스턴스가 초기화될 때 실행하는 생성자 함수
3. this