Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let myLib = (function(){
- this.libName = 'in lib';
- let obj = {
- libName: 'in obj',
- toCaps() {
- return this.libName.toUpperCase();
- }
- };
- console.log(obj.toCaps()); // IN OBJ (bound to the object)
- boundToCaps = obj.toCaps.bind(this);
- console.log(boundToCaps()); // IN LIB (bound to the myLib scope)
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement