Can there ever be a difference between:
var x = {
hello: 'world'
};
and
var x = {
'hello': 'world'
};
?
That is, under what conditions does giving a property name as a string have different results than giving it as a "raw" name? For example, I know that var x = {}; x['@£$%'] = 'bling!';
is valid (since any string can be a property), but x.@£$% = 'bling!'
won't work. Neither will language keywords or reserved keywords as property names (so var x = {for: 'good', class: 'y'};
won't work.
Anything else?
For example, what if
var hello = 'goodbye';
is defined in the above example? Or something else, like
function hello() {
return 'goodbye';
}
?
Should I always make my property names strings, just to be safe?