Created
August 8, 2012 14:44
-
-
Save asinbow/3295564 to your computer and use it in GitHub Desktop.
javascript simple class
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 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