How can I use d3.map()
to get [10, 12]
out of the following array?
var mydata = [
{ \'__data__\' : 10 },
{\'__data__\' : 12 }
];
You can't -- d3.map()
isn't for mapping a function across an array, but a shim for hashes. Briefly, while objects can be used like hashes, there are situations when unexpected behaviour can occur. A new Javascript standard proposes a solution to this, and until it is implemented, d3.map()
can be used to the same effect.
More information in the documentation.