Created
January 13, 2021 09:51
-
-
Save sematgt/09581b6a2e24bf534cced780d66df090 to your computer and use it in GitHub Desktop.
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
/* | |
Differences & Limitations: | |
Does not have its own bindings to this or super, and should not be used as methods. | |
Does not have arguments, or new.target keywords. | |
Not suitable for call, apply and bind methods, which generally rely on establishing a scope. | |
Can not be used as constructors. | |
Can not use yield, within its body. | |
*/ | |
// wrong | |
'use strict'; | |
var obj = { // does not create a new scope | |
i: 10, | |
b: () => console.log(this.i, this), | |
c: function() { | |
console.log(this.i, this); | |
} | |
} | |
obj.b(); // prints undefined, Window {...} (or the global object) | |
obj.c(); // prints 10, Object {...} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment