Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save toranb/3252324 to your computer and use it in GitHub Desktop.
How the new keyword works in javascript part 2
var Animal = function(omnivore) {
this.omnivore = omnivore;
}
var human = Animal(true);
console.log("the human is an omnivore " + human.omnivore);
//this will throw "TypeError: Cannot read property 'omnivore' of undefined"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment