Quick question out of curiosity:
code below works in Firefox and Chrome but not in Safari. Is this Javascript spec circumvented by Firefox and Chrome or is this a quirk in Safari?
var a = {};
a.var = "test";
in all (firefox, safari and chrome)
a["var"] = "test";
a.id = "another test";
works as expected.
Cheers, Jeroen.
var
is a reserved keyword so it might break when being used without being quoted.
according to the ecmascript specification its not allowed,
from ecmascript-262:http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf
7.6.1.1 Keywords
The following tokens are ECMAScript keywords and may not be used as Identifiers in ECMAScript programs.
break, do, instanceof, typeof, case, else, new, var, catch, finally, return, void, continue, for, switch, while, debugger, function, this, with, default, if, throw, delete, in, try
based on that safari is the preferred behavior
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With