The basic idea when using the => [ property=value ]
syntax to initialize a new entity is that the value must be a constant.
When stating for (let i=5; ...)
we define i
with a let
statement and then it is a variable and not a constant and this is why it is not accepted in the => [ ]
declaration.
One may note however that when writing a for loop like this : for (i:listOfValues) {...}
the i
is not a variable (there is no let
statement), it is considered as a constant extracted from the list of values. Hence it is possible to use i
as a value to initialize an entity with the => [ ]
syntax in that case.