我是新的面向对象的JavaScript因此,虽然我在练习我创造了这个代码在这里:的JavaScript对象的编程技巧
ap = []; //creating an empty array to hold persons;
pp = function (f, l, a, n, g) { //this is our object constructor
this.fname = f;
this.lname = l;
this.dob = a;
this.nat = n;
this.gen = g;
};
ap[ap.length] = new pp(f, l, a, n, g); // adding the newely created person to our array through the constructor function . btw parameters passed to the function are defined in another function (details in the jsfiddle file)
从这段代码的目的是为了获得用于创建和操作对象。所以我想知道是否有更简单的方法和更合理的方法来完成相同的任务。
好anyhelp将不胜感激,并表示感谢。
@ray这是一个可怕的建议。 – zerkms
ty @ray我真的很感谢你的忠告再次。 –