Skip to content

Instantly share code, notes, and snippets.

@richcollins
Created August 21, 2008 00:53
Show Gist options
  • Save richcollins/6472 to your computer and use it in GitHub Desktop.
Save richcollins/6472 to your computer and use it in GitHub Desktop.
Object.prototype.sayHello = function()
{
console.log("YOU FAIL");
}
Object.prototype.setAttributes = function(attributes)
{
for(var attName in attributes)
{
this[attName] = attributes[attName];
}
}
var helloer = {
helloString: "HELLO!",
sayHello: function(){
console.log(this.helloString);
}
}
helloer.sayHello();
// Prints "HELLO!" as expected
helloer.setAttributes({helloString: "GOODBYE"});
helloer.sayHello();
// Prints "YOU FAIL" instead of "GOODBYE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment