목록math (1)
코딩쌀롱
Mission1 (prototype, constructor, switch, Math, rest parameter)
prototype prototype은 말 그대로 객체의 원형. 함수는 객체 → 생성자도 객체 → 객체는 property를 가질 수 있고, prototype이라는 property를 가진다. (생성자 함수의 프로퍼티로 prototype을 갖는다) prototype에 저장된 속성들은 생성자를 통해서 객체가 만들어질 때 그 객체에 연결된다. function Ultra() {} Ultra.prototype.ultraProp = true; function Super() {} var t = new Ultra(); t.ultraProp = 4; Super.prototype = t; function Sub() {} Sub.prototype = new Super(); var o = new Sub(); console.log..
개발공부
2020. 12. 16. 12:07