Guest User

Untitled

a guest
Jan 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. // example demonstrating the scope of this inside an object
  2. myObject.mySum = function() {return this.a + this.b}
  3.  
  4. myObject.mySum()
  5. >>150
  6.  
  7. // another example
  8. myObject.newFunction = function() {console.log(this)}
  9.  
  10. myObject.newFunction()
  11. >> {a: 100, b: 50, mySum: ƒ, newFunction: ƒ}
Add Comment
Please, Sign In to add comment