// SuperType 생성자 function SuperType() { this.colors = ["red", "blue", "green"]; } // SubType 생성자 function SubType() {} SubType.prototype = new SuperType(); // SuperType을 프로토타입 상속 var instance1 = new SubType(); // SubType으로 instace1 생성 instance1.colors.push("black"); // colors 배열에 black 추가 document.write(instance1.colors + "<br>"); // red,blue,green,black var instance2 = new SubType(); // SubType으로 instace2 생성 document.write(instance2.colors + "<br>"); // red,blue,green,black // 두 colors 는 동일한 객체를 참조하고 있다. document.write(instance1.colors == instance2.colors) // true