I want to loop through an object array but the length property always returns one result less. When I have one dataset, I get 0. When I add another similar dataset, I get 1.
var currDatasets = $(this).data('graph').data.datasets;
console.log(currDatasets);
console.log(currDatasets.length);
// shows '0'
var test = [{ label: 'blah', value: 'blah' }];
console.log(test.length);
// shows '1'
The console output doesn't really differ from the lower result, except that {...} is missing from the [ ]-brackets. However when I use the length property, console.log returns 0.
This is what the console outputs with one datatag:
And this is what it outputs with two datatags: