I'm a bit lost with the following:
When I do a console.log of two different arrays, one is giving me the actual length but not the other.
Output of first array, with good length:
[Object, Object, Object]
  0: Object
  1: Object
  2: Object
  length: 3
  __proto__: Array[0]
Output of the second one, length should be 4 but is actually 0:
[A: Object, B: Object, C: Object, D: Object]
  A: Object
  B: Object
  C: Object
  D: Object
  length: 0
  __proto__: Array[0]
Why do my first array do have a correct length, but not the second one ?
Edit: this is the code generating the above output:
var links = [
  {source: "A", target: "B"},
  {source: "A", target: "C"},
  {source: "A", target: "D"}
];
var nodes = [];
// Compute the distinct nodes from the links.
links.forEach(function(link) {
  link.source = nodes[link.source] || (nodes[link.source] = {name: link.source});
  link.target = nodes[link.target] || (nodes[link.target] = {name: link.target});
});
console.log(links);
console.log(nodes);
 
     
    