Javascript keys are only strings!
You can use squares to access or set a value in an object, but that key is just getting converted to a string. And you can't loop through the keys and expect the keys to be objects... they're strings!
> a = {1: "x"}
{ '1': 'x' }
> a[/x/] = "y"
'y'
> a[1]
'x'
> a[/x/]
'y'
> a['1']
'x'
> a['/x/']
'y'
> for (var i in a) { console.log(i === 1); console.log(i === /x/) }
false
false
false
false
Tweet