在自定义对象的javascript中创建一个数组

Dav*_*vid 9 javascript

嗨我需要一些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;
        }
Run Code Online (Sandbox Code Playgroud)

我需要以这种方式创建一个数组.

var temp=new PricingData[]{new PricingData(1,2,3,4,5),new PricingData(1,2,3,4,5)};
Run Code Online (Sandbox Code Playgroud)

但这不起作用.我将通过服务器传递数据,所以我更喜欢类似于此的语法

Fel*_*ing 10

使用数组文字表示法来创建数组:

var tmp = [new PricingData(1,2,3,4,5), new PricingData(1,2,3,4,5)];
Run Code Online (Sandbox Code Playgroud)

有关数组的更多信息,请查看MDC - Array.