Skip to content

Instantly share code, notes, and snippets.

@mondalaci
Created April 29, 2014 13:22
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 mondalaci/11400212 to your computer and use it in GitHub Desktop.
Save mondalaci/11400212 to your computer and use it in GitHub Desktop.
JavaScript prototype testing
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