Skip to content

Instantly share code, notes, and snippets.

@guxuerui
Last active July 9, 2020 07:39
Show Gist options
  • Save guxuerui/e9cc1a2e987443620e7ccae4a66133b7 to your computer and use it in GitHub Desktop.
Save guxuerui/e9cc1a2e987443620e7ccae4a66133b7 to your computer and use it in GitHub Desktop.
笔试题--JS中的this
var length = 10;
function fn() {
console.log(this.length);
}
var obj = {
length: 5,
method: function(fn) {
fn();
arguments[0]();
}
};
obj.method(fn, 1);
// 结果是: 10 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment