Skip to content

Instantly share code, notes, and snippets.

@liammclennan
Created May 2, 2011 01:38
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 liammclennan/951079 to your computer and use it in GitHub Desktop.
Save liammclennan/951079 to your computer and use it in GitHub Desktop.
Basic JavaScript Constructor
function Person(name, age) {
this.name = name;
this.age = age;
}
Person.prototype = {
toString: function() {
return this.name + " is " + this.age + " years old.";
}
};
var john = new Person("John Galt", 50);
console.log(john.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment