how to create list of objects in javascript -
var employee = { column1: null, column2: null, create: function () { var obj = new object(); obj.column1 = ""; obj.column2 = ""; return obj; } };
in c# this:
list<employee> employees = new list<employee>(); (int = 0; < 10; i++) { employee emp = new employee() { column1 = "column 1 of emp" + i; column2 = "column 2 of emp" + i; } employees.add(emp); }
i need same in javascript.
pretty straight forward approach creating array of objects.
var employees = []; (var = 0; < 10; i++) { employees.push({ column1: 'column 1 of emp' + i, column2: 'column 1 of emp' + }); }
Comments
Post a Comment