Last active
September 8, 2016 17:56
-
-
Save obber/3086954b40bd896b2c2869385ed46f1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = function() { | |
console.log(this); | |
}; | |
// unwrapped | |
console.log(this); // window | |
// free function invocation | |
a(); // window | |
var dianne = { | |
greet: function() { | |
console.log('i\'m awesome'); | |
} | |
} | |
var person = { | |
name: 'kan', | |
walk: function() { | |
console.log(this.name + ' is walking'); | |
return dianne; | |
}, | |
greet: function() { | |
// assuming we do person.greet(): | |
// this = person | |
// person.name => 'kan' | |
console.log(this.name + ' is my name'); | |
} | |
} | |
person.walk().greet(); | |
var Human = function(name, age) { | |
this.name = name; | |
this.age = age; | |
this.walk = function() { | |
return this.name + ' is walking'; | |
} | |
} | |
var me = new Human('kan', 24); | |
var oliver = new Human('oliver', 24); | |
console.log(me === oliver); | |
function a() {}; | |
console.log(me.walk === oliver.walk); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment