Definition of name property in assignment expression

This first snippet is described under assignment operators:

e. If IsAnonymousFunctionDefinition(AssignmentExpression) and IsIdentifierRef of LeftHandSideExpression are both true, then

i. Let hasNameProperty be HasOwnProperty(rval, “name”).

ii. ReturnIfAbrupt(hasNameProperty).

iii. If hasNameProperty is false, perform SetFunctionName(rval, GetReferencedName(lref)).

When you assign to a MemberExpression, as in your last snippet, IsIdentifierRef(LeftHandSideExpression) is false and no conversion takes place.

If you search the standard for IsAnonymousFunctionDefinition you’ll find a couple of other cases where this logic is used (object initializers, destructuring assignments).

IsIdentifierRef is defined twice (here and here), and both definitions boil down to “if an expression is IdentifierReference return true otherwise return false”, where IdentifierReference is an Identifier (the yield stuff is for backward compatibility with non-strict code).

Leave a Comment

tech