Created
April 29, 2014 13:22
-
-
Save mondalaci/11400212 to your computer and use it in GitHub Desktop.
JavaScript prototype testing
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
function Project(basedOnJsObject) { | |
this.code = basedOnJsObject.code; | |
} | |
Project.prototype = { | |
getCode: function() { | |
return this.code; | |
} | |
} | |
p1 = new Project({code:'proj1'}) | |
> Project {code: "proj1", getCode: function} | |
p2 = new Project({code:'proj2'}) | |
> Project {code: "proj2", getCode: function} | |
p1.getCode() | |
> "proj1" | |
p2.getCode() | |
> "proj2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment