Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

move items from one log to another typescript

var array1 = [1, 2, 3, 4, 5];
var array2 = [];

for(var i = 0; i < array1.length; i++) {
  array2.push(array1[i]);
  array1.splice(i, 1);
  i--; //decrement i IF we remove an item
}

console.log(array1); //[]
console.log(array2); //[1, 2, 3, 4, 5]
 
PREVIOUS NEXT
Tagged: #move #items #log #typescript
ADD COMMENT
Topic
Name
4+7 =