Reputation: 377
I have an Array of objects and need to add new object as per some criteria. As consist list of objects as:
How to create new object which have all above properties and add to end of array using jquery?
Upvotes: 0
Views: 1221
Reputation: 1608
1.you can create a plain object in jquery
Ex:
var foo = { foo: "bar", hello: "world" };
refer : http://api.jquery.com/jquery/
2.you can create array in jquery
Ex:
var array = new Array();
Ex: array.push(foo);
refer : https://www.sitepoint.com/declare-arrays-jquery/
Upvotes: 0
Reputation: 337733
You can use the push()
method of the array to do this:
// assuming 'arr' is the variable containing the array you showed in the question:
arr.push({
AgentOnlyFieldFlag: 'False',
// other properties here...
});
Also note that you should really change the AgentOnlyFieldFlag
, BlankCaptionFlag
and PromatchFlag
to contain boolean values instead of strings.
Upvotes: 1