Say I have an array: [['TEST1'], ['TEST2'], ['TEST3'], ['TEST4'], ['TEST5']]
and I want to move all the elements to the "top" level of the array, so it would end up like so:
['TEST1', 'TEST2', 'TEST3', 'TEST4', 'TEST5']
I have a few mockups below, but I'm wondering what the recommended route might be.
var test = [['TEST1'], ['TEST2'], ['TEST3'], ['TEST4'], ['TEST5']];
var testarr = [];
test.forEach(function(e){
testarr.push(e[0]);
})
console.log(testarr);
Or
var test = [['TEST1'], ['TEST2'], ['TEST3'], ['TEST4'], ['TEST5']];
for (i = 0; n = test.length, i < n; i++){
test[i] = test[i][0]
}
console.log(test);
Output of both:
[ 'TEST1', 'TEST2', 'TEST3', 'TEST4', 'TEST5' ]