访问对象的阵列的属性 [英] Accessing properties of an array of objects
本文介绍了访问对象的阵列的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
pretty基本的问题,我想,但我无法找到该信息。
pretty basic question I think, but I couldn't find info on that.
到D3我解析CSV和每个对象看起来像这样
Through d3 I parse a csv and each object look like this
name: "whatever"
number: "52"
如何访问所有属性数字作为一个数组的数组,而无需创建一个新的数组,推动每个元素?
How can I access the array of all the properties "number" as an array without creating a new array and pushing each element?
推荐答案
使用<一个href=\"https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/map\">array.map:
var numbers = objects.map(function(o) { return o.number; });
这篇关于访问对象的阵列的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文