I was wondering if there's any difference between this (property name initializer):
var buffalo = {
word:"buffalo"
}
and this (string initializer):
var cow = {
"word":"cow"
}
There seems to be no real difference that I can tell. Is there a specific reason to use one or the other? Or is it just a matter of preference?
Both variables can be accessed using dot syntax or brackets:
alert(buffalo.word+", "+cow.word); // buffalo, cow
alert(buffalo["word"]+", "+cow["word"]);// buffalo, cow
Thanks for your help!