A colleague, by mistake wrote this code:
var parameters = [];
// some lengthy code here
parameters.firstParameter = "first parameter value";
parameters.secondParameter = "second parameter value";
He had declared parameters
variable as an array, but somewhere else he had used it as an object, adding parameters to it.
The results of testing the type of this parameter is as follow (in Google Chrome's console):
parameters;
// prints []
typeof parameters;
// prints "object"
parameters instanceof Array;
// prints true
So, is it an object or an array at last? Or does it have a dual nature, both array and object at the same time?