Hi all,
I like the property setting shorthand feature for object literals, which is (to remind you):
compiling to
{
a: a,
b: b,
x: c.x,
y: c.y
}
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, 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
Hi all,
I like the property setting shorthand feature for object literals, which is (to remind you):
{ a b c.x c.y }compiling to
However, I've been surprised not being able to do something like:
{ a.b.c x.y.z }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:
{ JSON.parse input .property }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