I'm trying to fill an array with new objects, but the only thing I get is - Uncaught TypeError: product is not a constructor
Here's my code for obj. constructor:
function product(id, preview, colors, sizes, title, price) {
this.id = id;
this.preview = preview;
this.colors = colors;
this.sizes = sizes;
this.title = title;
this.price = price;
};
and code for loop:
var products = [];
for( i=0; i<db.length; i++) {
var xyz = db[i];
products[i] = new product( xyz.id, xyz.preview, xyz.colors, xyz.sizes, xyz.title, xyz.price );
};
here's "minfied" code block example: https://jsfiddle.net/cujrfhyL/1/
-Thanks in advance.
new product();) Except for the fact that product6566 and product6646 could throw syntaxerror as they are undefined, but I am guessing that is a typonewwhen creating a product.