Even though this is clearly a duplicate of Does JavaScript Guarantee Object Property Order?, I'll go ahead and answer anyway.
There is zero guarantee of order in your "unordered collection of properties". However with modern implementations of Javascript, you can expect that the properties will usually be in order as you defined them.
As long as the expected order is preferable, but not critical, it is reasonable in most cases to just assume they will be in order. But if your business logic depends on that order to be guaranteed, then you definitely need to rethink your strategy.
Okay. I see now what you are actually asking. In this particular context, the answer is "yes and no".
Your functions are being called statically as your object is being defined. So the function defining property a
will always be called before the function defining property b
.
However, console.log
is an asynchronous function, and you cannot rely on it to log value A
before it logs value B