Skip to content

Instantly share code, notes, and snippets.

@asinbow
Created August 8, 2012 14:44
Show Gist options
  • Save asinbow/3295564 to your computer and use it in GitHub Desktop.
Save asinbow/3295564 to your computer and use it in GitHub Desktop.
javascript simple class
function Person(id, name) {
this.id = id;
this.name = name;
this.toString = function() {
return "" + this.id + ": " + this.name;
}
var test = function() {
alert(123);
}
}
var person = new Person(1, "asinbow");
console.log(person.toString());
var Person = function(id, name) {
return {
toString: function() {
return "" + id + ": " + name;
}
}
};
var person = Person(2, "asinbow");
console.log(person.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment