javascript 대상 단순 인 스 턴 스

//       ,         .
	//             ,               。          ,          .
	//  prototype      .
	function Dog(option){
		this.init(option);
	}
	
	Dog.prototype.init=function(option){//init     
		this.name=option.name;
		this.age=option.age;
		this.dogFricends=option.dogFricends;
	}
	
	Dog.prototype.eat=function(someThing){//  
		console.log(this.name+' '+someThing);
	}
	
	Dog.prototype.run=function(someWhere){//  
		console.log(this.name+' '+someWhere);
	}
	
	var smallDog=new Dog({name:'  ',age:11,dogFricends:['  ','  ']});//  
	var bigDog=new Dog({name:'  ',age:18,dogFricends:['  ','  ','hh']})//  
	
	console.log(smallDog.eat===bigDog.eat)//true

좋은 웹페이지 즐겨찾기