프로토타입(Prototype) 기반 언어 입니다. 여기서 프로토타입은 원형 객체를 의미한다. 또한, 프로토타입 객체도 또 다시 상위 프로토타입 객체로부터 메소드와 속성을 상속 받을 수도 있고 그 상위 프로토타입 객체도 마찬가지로 받을 수 있다. 이를 프로토타입 체인(prototype chain)이라고 부른다.
function Person(first, last, age, gender, interests) {
this.name = {
this.first = first;
this.last = last;
}
this.age = age;
this.gender = gender;
this.interests = interests;
Person.prototype.bio = function() {
var string = this.name.first + ' ' + this.name.last + ' is ' + this.age + ' years old. ';
var pronoun;
}
var person1 = new Person('Bob', 'Smith', 32, 'male', ['music', 'skiing']);
person1.valueOf()
여기서 메소드 속성들이 다른 객체로 복사되는 것이 아니라 체인을 타고 올라가며 접근할 뿐이다.
__proto__
- 프로퍼티나 메서드에 접근하기 위해 사용하는 속성이다.