You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like the property setting shorthand feature for object literals, which is (to remind you):
{
abc.xc.y
}
compiling to
{a: a,b: b,x: c.x,y: c.y}
However, I've been surprised not being able to do something like:
{
a.b.cx.y.z
}
to compile to
{c: a.b.c,z: x.y.z}
as this however seems intuitive: simply take the last part of the property access as the property name, like (whatever-I-do-to-reach-the-value).property, giving property: (whatever-I-do-to-reach-the-value).property.
With a real example:
{
JSON.parse input .property
}
would give:
{property: JSON.parse(input).property}
FYI, the first non-working example I gave you (with simple multiple dots access) triggers the following error: Parse error on line 2: Unexpected 'DOT'
While the last one gives: Parse error on line 2: Unexpected 'CALL('
Best regards
The text was updated successfully, but these errors were encountered:
Hi all,
I like the property setting shorthand feature for object literals, which is (to remind you):
compiling to
However, I've been surprised not being able to do something like:
to compile to
as this however seems intuitive: simply take the last part of the property access as the property name, like
(whatever-I-do-to-reach-the-value).property
, givingproperty: (whatever-I-do-to-reach-the-value).property
.With a real example:
would give:
FYI, the first non-working example I gave you (with simple multiple dots access) triggers the following error:
Parse error on line 2: Unexpected 'DOT'
While the last one gives:
Parse error on line 2: Unexpected 'CALL('
Best regards
The text was updated successfully, but these errors were encountered: