JavaScript 获取数组对象中某一值封装为数组

1、获取数组对象中某一值封装为数组(一)

data = [["2000-06-05",116],["2000-06-06",129]];
var dateList = data.map(function (item) {
    return item[0];
});
console.log(dateList);

==>["2000-06-05","2000-06-06"]

 

2、获取数组对象中某一值封装为数组(二)

data=[{"prodDate": "2018-01-02","oilProdDaily": 1.68},{"prodDate": "2018-01-03","oilProdDaily": 1.68}]; 

var prodData=data.map(function (item) {
    
return item['prodDate'];
});
console.log(prodData);

==>["2018-01-02","2018-01-03",...]

 原文:https://www.cnblogs.com/bigroc/p/10322606.html

posted @ 2019-01-26 09:39  bigroc  阅读(15825)  评论(0编辑  收藏  举报