How do I remove 1 and 3 from below array in array?
[[1,2], [3,4,5]]
[[2],[4,5]]
was thinking about pop() but stuck somewhere.
How do I remove 1 and 3 from below array in array?
[[1,2], [3,4,5]]
[[2],[4,5]]
was thinking about pop() but stuck somewhere.
Try to use JavaScript built-in function shift().
var a = [[1,2], [3,4,5]];
a.map(item => {
item.shift();
return item;
});
console.log(a); // [[2], [4, 5]]
Official guide: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
const a = [[1,2], [3,4,5]];
console.log(
a.map(item => item.splice(1))
)
Basically you're mapping each item of the array with the same array without the first element (since splice mutate the array).
If you want have a copy also of the inner array, then you should use slice instead.