Created
March 4, 2013 14:36
-
-
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 …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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