我有一个由数组组成的数组,每个数组包含对象。以下是我参考的简化版本(这是我原始数组的console.log)-
Array - [Array(2), Array(3), Array(2)]
每个数组都有以下格式的对象(以上面的第一个数组为例)-
Array(2) -
0: {name: "test", score:40, date: "2018-09-18T00:00:00.000Z"}
1: {name: "test2", score:50 date: "2018-09-18T00:00:00.000Z"}
其他数组与此类似,具有相同的属性但不同的值。
我试图从每个对象中提取名称属性。我尝试了下面的代码,但最终得到了未定义的值:
const test1= array1.map(x=> x.values) // this gives me the array of arrays
const test2 = test1.map(function(y){return y.name})// this is my attempt to get the 'name' attribute from all of the arrays that include the objects.
在这里我错过了什么?有更好的方法使用箭头函数获取属性吗?