Skip to content

Instantly share code, notes, and snippets.

@kshirish
Created February 14, 2015 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kshirish/1bf7db7b4796f69131af to your computer and use it in GitHub Desktop.
Save kshirish/1bf7db7b4796f69131af to your computer and use it in GitHub Desktop.
javascriptissexy
// 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