new로 객체생성자함수 만들기

조다희·2021년 2월 25일
0
function Person(name, first, second, third){
    this.name=name;
    this.first=first;
    this.second=second;
    this.sum = function(){
        return this.first+this.second;
    }
}
 
var kim = new Person('kim', 10, 20);
var lee = new Person('lee', 10, 10);
console.log("kim.sum()", kim.sum());
console.log("lee.sum()", lee.sum());
profile
블로그 옮김 https://daheejo.tistory.com/

0개의 댓글