Constructor . prototype
+----------------
|               /
|              /
|             /
|            /
|           /
instance . __proto__
var Person = function (name) {
	this._name = name;
};
Person.prototype.getName = function() {
	return this._name;
};
var suzy = new Person('Suzy');
suzy.__proto__.getName(); // undefined
// 왜냐면, getName() 의 this는 suzy.__proto__ 이기 때문에..
// suzy.__proto__ === Person.prototype 이기 때문에..
// Person.prototype 은 _name 이 없다.
suzy.getName(); // Suzy
// __proto__ 는 생략할 수 있다.
// 생략하는 경우, this 는 해당 instance 가 된다.

constructor 프로퍼티

생성자 함수의 prototype 프로퍼티 안에 constructor 프로퍼티가 있다. 원래의 생성자 함수(자기 자신)을 가리킨다.

var arr = [1,2];
Array.prototype.constructor === Array
arr.__proto__.constructor === Array
arr.constructor === Array

Object

Object.prototype 에는 범용적인 메서드만 있고, 객체 전용 메서드는 Object 생성자 함수에 static 하게 들어있다.

Class

var ES6 = class {
	constructor (name) {
		this.name = name;
	}
	static staticMethod() {
		return this.name + ' static';
	}
	method() {
		return this.name + ' method';
	}
};
var es6Instance = new ES6('es6');
console.log(ES6.staticMethod()); // ES6 static
console.log(es6Instance.method()); // es6 method