Answers for "typescript array insert"

21

javascript insert item into array

var colors=["red","blue"];
var index=1;

//insert "white" at index 1
colors.splice(index, 0, "white");   //colors =  ["red", "white", "blue"]
Posted by: Guest on July-22-2019
5

add item to array javascript

const arr1 = [1,2,3]
const newValue = 4
const newData = [...arr1, obj] // [1,2,3,4]
Posted by: Guest on April-17-2020
0

typescript array insert

const months = ['Jan', 'March', 'April', 'June'];
months.splice(1, 0, 'Feb');
Posted by: Guest on March-29-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language