name anonymous functions on property assignments

a.d.bergi at web.de a.d.bergi at web.de
Tue Jul 28 20:21:28 UTC 2015


> a big concern for me is what to do about functions being passed around

Nothing happens to them. This feature is only about assignments where the right hand side consists of a function expression.

> var a = {};
> a.foo = function () {}
> // .name would be "foo"

Yes.

> var b = {};
> b.bar = a.foo;
> // .name would be "bar"

No, the name would still be "foo". It doesn't change when the function already has a `.name`, and `a.foo` is not an anonymous function definition but a memberexpression.

> doThing(()=>{})
> // what is .name?

Nothing. There is no identifier hanging around the function expression. It's anonymous, and will stay so.

You see, no magic! :-)

 Bergi


More information about the es-discuss mailing list