array insertion javascript
Array.prototype.insert = function ( index, item ) {
this.splice( index, 0, item );
};
array insertion javascript
Array.prototype.insert = function ( index, item ) {
this.splice( index, 0, item );
};
add elements to an array with splice
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;
function myFunction() {
fruits.splice(2, 0, "Lemon", "Kiwi");
document.getElementById("demo").innerHTML = fruits;
}
how to insert a value into an array javascript
var list = ["foo", "bar"];
list.push("baz");
["foo", "bar", "baz"] // result
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us