Skip to content

Instantly share code, notes, and snippets.

@toranb
Created August 3, 2012 22:47
Show Gist options
  • Select an option

  • Save toranb/3252333 to your computer and use it in GitHub Desktop.

Select an option

Save toranb/3252333 to your computer and use it in GitHub Desktop.
How the new keyword works in javascript part 3
var Animal = function(omnivore) {
this.omnivore = omnivore;
}
var human = {};
Animal.apply(human, [true]);
console.log("the human is an omnivore " + human.omnivore);
//this will print "the human is an omnivore true"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment