Created
February 14, 2015 11:24
-
-
Save kshirish/1bf7db7b4796f69131af to your computer and use it in GitHub Desktop.
javascriptissexy
This file contains hidden or 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
// Careful with arrays | |
function Class(){ | |
this.array = []; | |
} | |
Class.prototype.anotherArray = []; | |
var obj = new Class(); | |
var anotherObj = new Class(); | |
obj.array.push('Dew'); | |
obj.anotherArray.push('Frost'); | |
console.log(obj); | |
console.log(anotherObj); | |
// jQuery event callbacks | |
var obj = { | |
show: function(callback){ | |
callback && callback.call(this); | |
} | |
}; | |
obj.show(function(){ | |
// access that this here .. | |
console.log(this) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment