关于JS的this和构造函数问题

function People() {

}

People.prototype.say = function () {

    alert("hello");

}


function Student() {

}

Student.prototype = new People();

var superSay = Student.prototype.say;


Student.prototype.say = function () {

    superSay.call(this);            // 为什么会是"hello"?

    alert("stu-hello");

}

var s = new Student();

s.say();

如代码中注释,superSay.call(this)为什么会是People.prototype.say函数被调用?this指向谁?


12345678_0001
浏览 441回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript