Splice works fine on a regular list. But when I try to use it for a list in a list, it gives me an error. Is there any way I can delete an element from a list in a list?
I tried this:
let arr = [[], [0, 1, 2, 3]];
arr[1].splice(0,1);
console.log(arr[1]);
I was expecting the output to be [1, 2, 3]. Instead, I got a TypeError.
New contributor
August is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.