-1
setTimeout
은 아래 코드에서 작동하지 않습니다.프로토 타입 및 setTimeous
내가 그것을 어떻게 를 해결할 수 있습니까?
function Human(name, surname, sex) {
this.name = name;
this.surname = surname;
this.sex = sex;
};
Human.prototype.wash = function() {
console.log(this.sex + ' ' + this.name + this.surname + ' ' + 'takes a cleaner and start washing')
}
Human.prototype.washing = function() {
var that = this;
setTimeout(function() {
console.log(that.name + 'still washing...'), 3000
});
};
function Human1(name, surname, sex) {
Human.apply(this, arguments);
};
Human1.prototype = Object.create(Human.prototype);
Human1.prototype.constructor = Human1;
Human1.prototype.wash = function() {
Human.prototype.wash.apply(this);
Human.prototype.washing.apply(this);
console.log(this.name);
};
var Andrey = new Human1('Andrey', 'Balabukha', 'male');
Andrey.wash();
어떻게 작동해야합니까? 여기에'console.log (this.name);가 무엇을 기대합니까? ' 'setTimeout'에서'3000'을 잘못된 위치에 넣습니다. –