在自定义对象的javascript中创建一个数组 [英] Create an array in javascript of custom objects
本文介绍了在自定义对象的javascript中创建一个数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我需要一些javascript帮助。
Hi I need some help with javascript.
function PricingData(id,method,freq,service,price) {
this.ID=id;
this.PaymentMethod_ID=method;
this.PaymentFrequency_ID=freq;
this.Service_ID=service;
this.Price=price;
}
我需要以这种方式创建一个数组。
I need to create an array in this way.
var temp=new PricingData[]{new PricingData(1,2,3,4,5),new PricingData(1,2,3,4,5)};
但这不起作用。我将通过服务器传递数据,所以我更喜欢与此类似的语法
but this doesn't work. I'm going to pass the data in through the server so I would prefer syntax similar to this
推荐答案
使用数组文字表示法创建一个数组:
Use array literal notation to create an array:
var tmp = [new PricingData(1,2,3,4,5), new PricingData(1,2,3,4,5)];
有关数组的更多信息,请查看 MDC - Array 。
For more information about arrays have a look at MDC - Array.
这篇关于在自定义对象的javascript中创建一个数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文