I ve创建了一个灰页,将为我提供一部全面的用户信息的XML文件。 我不敢肯定,这是创造和充实我的习惯 j器的最佳途径。 我以两种方式看待这些问题:
function User() {
this.Id;
this.FirstName;
this.LastName;
this.Title;
}
以及
var User2 = {
Id: null,
FirstName: null,
LastName: null,
Title: null
}
我可以通过做如下事情来充实其中的每一部分:
//first object
User.Id = 1
//second object
User2.FirstName = John
造物的方法是否优于其他方法?
Edit: A year 以及 a half later I saw that this question got the popular badge, so I just wanted to mention that today I am using Crockford s module pattern.