Let’s say you have an object literal:
var d = {
x: +'35',
y: '25'
};
And an anonymous function:
function (d) {
return d.y0 + d.y;
}
When I experiment with this code, I get “undefined” in place of d.y0. But there is plenty of d3.js code that accesses a value by appending 0 to its key. What does this 0 do?
In JavaScript,
d.y0is undefined unlessdhas a property namedy0. I’m not familiar with d3 but if it uses pure JavaScript then the only way they can reference properties with an appended 0 is if the objects from which they’re referencing the properties have a property with that name.