Skip to content
New issue

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

Arrow functions should *always* overwrite this #1878

Closed
gfwilliams opened this issue Jul 13, 2020 · 0 comments
Closed

Arrow functions should *always* overwrite this #1878

gfwilliams opened this issue Jul 13, 2020 · 0 comments

Comments

@gfwilliams
Copy link
Member

@gfwilliams gfwilliams commented Jul 13, 2020

var outer = {
  data : "oops.",
  go : function() {
    return {
      data : "Yay!",
      arrow : () => console.log(this.data),
      normal : function() { console.log(this.data); }
    };
  }
};
var a = outer.go();
var b = {
  data : "Yay!",
  arrow : () => console.log(this.data),
  normal : function() { console.log(this.data); }
};
  

a.arrow();
//oops.
b.arrow();
// should be 'undefined', but currently returns `Yay!` <============================

a.normal();
//Yay!
b.normal();
//Yay!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant