I have a multi dimensional array like this.
var myArray = [['aaa','1','2.33','44'],['bbb','1','2.33','44'],['ccc','1','2.33','44']]
I want to remove all the first element to get a result like this.
var myArray = [['1','2.33','44'],['1','2.33','44'],['1','2.33','44']]
Please Help me. Thanks
I have a multi dimensional array like this.
var myArray = [['aaa','1','2.33','44'],['bbb','1','2.33','44'],['ccc','1','2.33','44']]
I want to remove all the first element to get a result like this.
var myArray = [['1','2.33','44'],['1','2.33','44'],['1','2.33','44']]
Please Help me. Thanks
Share Improve this question edited Apr 28, 2017 at 7:13 Suren Srapyan 68.7k14 gold badges125 silver badges117 bronze badges asked Apr 28, 2017 at 7:11 VahidVahid 1191 gold badge2 silver badges14 bronze badges2 Answers
Reset to default 9Use .forEach to loop over the nested arrays and then .splice them. Splice will remove the first item in the nested array and effect the current array.
var myArray = [['aaa','1','2.33','44'],['bbb','1','2.33','44'],['ccc','1','2.33','44']];
myArray.forEach(array => array.splice(0,1));
console.log(myArray);
Base on the ment you can also use .shift() function to remove the first item.
var myArray = [['aaa','1','2.33','44'],['bbb','1','2.33','44'],['ccc','1','2.33','44']];
myArray.forEach(array => array.shift());
console.log(myArray);
You can try this
var myArray = [['aaa','1','2.33','44'],['bbb','1','2.33','44'],['ccc','1','2.33','44']];
var done = function(){
console.log(myArray);
};
myArray.forEach(function(array){
array.splice(0,1);
done();
});
Output
[['1','2.33','44'],['1','2.33','44'],['1','2.33','44']];