You apes just don't get it.

My fellow bunny didn't ask
"What am I doing?" or
"How do I do this?". The question was
"Why does javascript they require it this way?", coupled with the observation that it
Just. Doesn't. Make. Sense.
fuzzybabybunny is a novice javascripter and I'm a veteran javascripter and we both think alike on this.
I have no answer to
"Why?" but I can also see no reason why the syntax for object initialisation
has to use colons instead of equals. The parsing would work whichever token was used. I'd go further and say that it doesn't need to use commas instead of semicolons to terminate a property initialisation.
For me, this crops up every now and then when I'm coding a new area of functionality. I'll start with some code which sets up some variables and then go on to use them. As the functionality grows I might add some more variables and then at some point it'll look like it may be handier to have them in an object (which may, further down the road, grow into a class).
I then have to turn something that looks like
Code:
var foo = 6295141.3;
var bar = "Right you are";
var the = "Wednesday";
var elephant = 0.5;
into
Code:
var obbjy = {
foo: 6295141.3,
bar: "Right you are",
the: "Wednesday",
elephant: 0.5
};
Now wouldn't it be a lot easier if the object initialisation used equals and the terminator was semicolon? Then, rather than faffing about editing each and every assignment, all I'd need to do would be to take out the
vars, pop some braces around the lot and assign that to the new object variable.
ps. Anyone talking about JSON is barking up the wrong tree. JSON is relatively new. It's a subset of javascript but it has nothing to with javascript's
design. The only design decision of JSON is the requirement for inefficiency, namely the use of quotes around property names that do not need them.
{ "UnnecessaryQuotes": true }