Last active
July 9, 2020 07:39
-
-
Save guxuerui/e9cc1a2e987443620e7ccae4a66133b7 to your computer and use it in GitHub Desktop.
笔试题--JS中的this
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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