jquery - Object insert issue in JavaScript array -


this question has answer here:

i have javascript array below:

[     {type: 'text', name: 'title', id: 'title', placeholder: 'type here'},     {type: 'textarea', name: 'description', id: 'description', placeholder: 'type here'} ] 

now want inset {type: 'text', name: 'age', id: 'age', placeholder: 'type here'} after first object. final result set looks like:

[     {type: 'text', name: 'title', id: 'title', placeholder: 'type here'},     {type: 'text', name: 'age', id: 'age', placeholder: 'type here'}     {type: 'textarea', name: 'description', id: 'description', placeholder: 'type here'} ] 

i want in plain javascript or jquery!

like this:

var = [     {type: 'text', name: 'title', id: 'title', placeholder: 'type here'},     {type: 'textarea', name: 'description', id: 'description', placeholder: 'type here'} ]  var b= {type: 'text', name: 'age', id: 'age', placeholder: 'type here'}   a.splice(1,0,b);  console.log(a) 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -