How to extract value from an array of array

前端 未结 6 1018
旧巷少年郎
旧巷少年郎 2021-01-29 03:32

I have an array of array stored. I need to extract the particular value from this arrays.

e.g allarray contain the list of arrays allarray= [Array[3],Array[3],Array[3]]

6条回答
  •  旧巷少年郎
    2021-01-29 03:48

    This is what the Array.prototype.map function is for:

    var arr = [["a1","b1","c1"],["a2","b2","c2"],["a3","b3","c3"]];
    
    var theValues = arr.map(function(inner) {return inner[2]});
    
    alert(theValues.join(', '));
    

提交回复
热议问题