Convention for Javascript Domain Model Objects
问题 If I have to create a domain model object in C# I might do something like this: public class Person { Public string Name { get; set; } Public string Gender { get; set; } Public int Age { get; set; } } In Javascript, what is the convention for defining such objects? I'm thinking something like this: NAMESPACE.Person = function() { this.name = ""; this.gender = ""; this.age = 0; } 回答1: Yeah, spot on basically. The only thing to add is that you should prototype methods on. How you proto can be