Skip to content

Instantly share code, notes, and snippets.

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 AugustoPedraza/5082610 to your computer and use it in GitHub Desktop.
Save AugustoPedraza/5082610 to your computer and use it in GitHub Desktop.
If a function is invoked with the "new" prefix, then a new object will be created with a hidden link to the value of the function's PROTOTYPE member, and "this" will be bound to that new object. The "new" prefix also changes the behavior of the "return" statement... //Show code... Functions that are intended to be used with the "new" prefix are …
//Create a constructor function called Quo.
//It makes an object with a status property.
var Quo = function(string){ this.status = string; };
//Gives all instances of Quo a public method called getStatus.
Quo.prototype.getStatus = function( ){ return this.status; };
//Make an instance of Quo.
var myQuo = new Quo("confused");
console.log(myQuo.getStatus( ));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment