Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. let myLib = (function(){
  2. this.libName = 'in lib';
  3.  
  4. let obj = {
  5. libName: 'in obj',
  6. toCaps() {
  7. return this.libName.toUpperCase();
  8. }
  9. };
  10.  
  11. console.log(obj.toCaps()); // IN OBJ (bound to the object)
  12. boundToCaps = obj.toCaps.bind(this);
  13. console.log(boundToCaps()); // IN LIB (bound to the myLib scope)
  14. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement