자바스크립트 객체 예제1 자바스크립트 객체 예제 //방법1.function Car(name,color){this.name = name;this.color = color;this.show = function(){console.log(name, color)}} var car1 = new Car('morning','blue');car1.show(); //방법2. 프로토타입 이용 function BigCar(name, color){this.name = name;this.color = color;} BigCar.prototype.show = function(){console.log('bigcar' ,this.name , this.color)}//자식 객체 1var bigcar1 = new BigCar('churare','white');bigcar1.show().. 2018. 10. 15. 이전 1 다음