//생성자 함수 = 붕어빵 틀
function Heroes(name, age){
this.name = name;
this.age = age;
this.fuk = function(){
log(this,firstname+" "+this.age);
}
}
//인스턴스 = 붕어빵
bar superMan = new Heroes('슈퍼맨','30');
log(superMan);
log(superMan.fuk();
----------------------------------------------------
//생성자 함수
function Heroes(name, age){
this.name = name;
this.age = age;
}
//프로토타입
Heroes.prototype.fuk = function(){
log(this,firstname+" "+this.age);
}
//생성 클래스의 어버이로, 어버이에 있는 모든것은 상속된다.
//클래스 생성시 자동으로 생성됨.
log(heores.fuk());
//log,dir함수로 _proto_확인가능
---------------------------
//constructor 생성자 함수 확인
log(str.constructor);
-----------------
//this
//일반함수 this -> window
//중첩함수 this -> window
//이벤트에서 this -> 이벤트 객체 btn.addeventlistener <- this = btn
//메서드에서 this -> 객체
var obj = {
id: function(){log(this);
} <- this = obj
//메서드 안에 함수 this -> window
------------------------------
//that
var obj = {
var that = this; //this를 대신하는 관용구
id: function(){log(that);
}
-------------------------------
//템플릿 리터럴
//``,
log('my name is ${name}');
function Customer(name, img, txt){
this.name = name;
this.img = img;
this.txt = txt;
}
function createCustomer(name, img, txt){
var fullImg = 'img/customer-${img}.jpg;
var customer = Cusmoer(name, fullImg, txt);
arr. push(cusomer);
}