String properties vs Number properties

Edit on GitHub

Iterate on properties with number or string

Setup

var obj = {};
var strNumbers = [];
var numbers = [];

for(var i = 0; i < 1000; i++) {

numbers.push(i);
strNumbers.push(i + '');
obj[i + ''] = true;

}

Tests

  • String properties

    var toAssign;
    
    for(var i = 0; i < 1000; i++) {
    toAssign = obj[strNumbers[i]];
    }
  • Number properties

    var toAssign;
    
    for(var i = 0; i < 1000; i++) {
    toAssign = obj[numbers[i]];
    }