Object insert issue in JavaScript array

<>

This question already has an answer here:

Answers


like this:

var a = [
    {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)

If your array is in variable array, then:

array.splice(1, 0, {
    type: 'text',
    name: 'age',
    id: 'age',
    placeholder: 'Type here'
});

The 1 means that you want to place it at index 1, 0 means you want to delete 0 items from the array. See splice documentation, it is quite the abomination of a method with 2 purposes of which both are never used at the same time :D


Need Your Help

How can I execute a sql command with a blob param in dbx?

delphi dbx

I have a TSqlDataSet which has a blob field, I need to get the data of this blob field in the BeforeUpdateRecord event of the provider and execute an update command, I've tried this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.