Guest User

Untitled

a guest
Oct 17th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. x = "Global";
  2.  
  3. objArrow = {
  4. x: "Object with arrow method",
  5. logX: () => { console.log(this.x); }
  6. }
  7.  
  8. objNormal = {
  9. x: "Object with normal method",
  10. // ES6 shorthand notation for normal function
  11. logX () { console.log(this.x); }
  12. }
  13.  
  14. objArrow.logX(); // "Global"
  15. arrowX = objArrow.logX;
  16. arrowX(); // "Global"
  17.  
  18. objNormal.logX(); // "Object with normal method"
  19. normalX = objNormal.logX;
  20. normalX(); // "Global"
Add Comment
Please, Sign In to add comment