Saturday, 14 September 2013

associative array: define the undefined?

associative array: define the undefined?

I just tried the following code (in javascript) which should return 'This
is totally undefined' which did not work:
var foo = {'foo' : 'bar', undefined : 'This is totally undefined!'};
alert( foo['toomany foobars'.match(/asdf/)] );
yet this works perfectly:
var foo = {'foo' : 'bar', undefined : 'This is totally undefined!'};
alert(foo[undefined]);
I don't understand, is there someone who can explain?
Thanks a lot in advance

No comments:

Post a Comment