We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function fn() { console.log(this.length); } var person = { length: 5, method: function (fn) { fn(); }, }; person.method(fn, 1);
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
这题考的是this的指向问题
1 当做函数调用的时候,指向window
2 对象方法调用的时候,指向调用对象
3 通过call,apply使用的时候,指向传入的第一个参数
4 构造函数创建实例对象的时候,构造函数内的this指向实例对象
function Fn(){ this.user = “111”; } var a = new Fn(); console.log(a.user); //111
5 箭头函数的this,指向调用环境中的this
No branches or pull requests
The text was updated successfully, but these errors were encountered: