그래서 난이 생성자 기능과 몇 가지 프로토 타입 방법이 함수 본문 제공 :JS : 프로토 타입 상속 자식 방법은 나에게
var test = function(name, surname){
this.name = name
this.surname = surname
}
test.prototype.hello = function(){
console.log("hello " + this.name)
}
test.prototype.hi = function(name){
console.log("hi " + this.name)
}
test.prototype.hi.surname = function(){
console.log("hi " + this.surname + this.name)
}
을 그리고 난이 같이 호출 : 왜
var hii = function(){
var x = new test("kevin", "vanhove")
x.hello()
x.hi.surname()
}()
입니다 x.hi.surname()에 대한 호출에서이 출력 (함수 본문)을 제공하고 있습니까? 당신이 기능이 "안녕하세요"에 대한 참조가 될 것입니다
x.hi.surname();
은 "성"함수 내에서 this
의 값을 호출
hello kevin
hi function(){
console.log("hi " + this.surname + this.name)
}
같은 문제 : http://stackoverflow.com/q/27327408/218196 –