I was worried that compiler may optimize such sings as order of properties 
initialization, while async/await may be a reason for doing so. Thank you.

четверг, 18 мая 2017 г., 13:50:54 UTC+3 пользователь Jakob Kummerow написал:
>
> An object literal {x: ..., y: ...} will always create the properties x and 
> y in this order. This is unrelated to async/await (in fact, if you dropped 
> all "async"/"await" keywords from your example, it would work exactly the 
> same).
>
> On Wed, May 17, 2017 at 7:13 PM, Aleksey <[email protected] 
> <javascript:>> wrote:
>
>> consider code
>>
>> ;(async () => {
>>   const o = {
>>     f: async () => {
>>       const x = await Promise.resolve(1)
>>       o.y = 3
>>       return x
>>     },
>>   }
>>   console.log({
>>     x: await o.f(),
>>     y: o.y,
>>   })
>> })()
>>
>> will output
>>
>> { x: 1, y: 3 }
>>
>> But if we change order of object field definition to
>>
>> ...
>> console.log({
>>   y: o.y,
>>   x: await o.f(),
>> })
>> ...
>>
>> result will be
>>
>>
>> { y: undefined, x: 1 }
>>
>> The question is: is this behavior guaranteed? I mean if sequence will be 
>> like
>>
>> console.log({
>>   x: await o.f(),
>>   y: o.y,
>> })
>>
>> would result always be like
>>
>> { x: 1, y: 3 }
>>
>>
>> and never like
>>
>> { y: undefined, x: 1 }
>>
>> ?
>>
>> Thanks
>>
>> -- 
>> -- 
>> v8-users mailing list
>> [email protected] <javascript:>
>> http://groups.google.com/group/v8-users
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "v8-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to