In `var anon = function () {};`, I was relying on `anon.name` being the
empty string. One of the packages this matters in is
https://www.npmjs.com/package/function.prototype.name, which attempts to
polyfill function names in IE. I fixed it by putting the function inside
`Object()`
https://github.com/ljharb/function.prototype.name/blob/master/test/tests.js#L7-L9
but that wouldn't be necessary without function name inference.On Sat, Jan 28, 2017 at 8:11 AM, T.J. Crowder < [email protected]> wrote: > On Sat, Jan 28, 2017 at 3:46 PM, Allen Wirfs-Brock > <[email protected]> wrote: > > > > > > > On Jan 27, 2017, at 7:26 AM, T.J. Crowder < > [email protected]> wrote: > > > > > > Two questions on the minor issue of the following not assigning a name > > > to the function: > > > > > > ```js > > > obj.foo = function() { }; > > > ``` > > > > > > 1) Am I correct that the only reason it doesn't (in spec terms) is > > > > > > No, the only reason it doesn’t is: by design, as directed by a decision > made within a TC39 meeting. > > Yes, obviously. :-) By "in spec terms" I meant -- and thought in > context was clear -- "in the language in the specification." I'm sorry > if it wasn't clear. > > > > would mean it would assign the name `foo`? > > > > Yes, and for > > cache[getUserSecret(user)] = function() {}; > > it would leak the secret user info as the value of name > > As does > > ```js > cache = { > [getUserSecret(user)]: function() {} > }; > ``` > > ...which while perhaps less likely for something called `cache` is, in > the general case, just as much of a potential "leak". If secrecy is > important, it's easily achieved: > > ```js > cache[getUserSecret(user)] = function entry() {}; > ``` > > > and for > > obj[someSymbol] = function() {} > > it would leak the Symbol value as the value of name > > It would *use* it as the name, yes, just like this does: > > ```js > obj = { > [someSymbol]: function() {} > }; > ``` > > Whether that's a *leak* depends on whether the code in question cares > about that information being exposed. And again if that secrecy is > important, it's trivially ensured (as above). > > > and for > > table[n]=function() {} > > name would likely be a numeric string > > Just as it does here: > > ```js > obj = { > [n]: function() {} > }; > ``` > > or here > > ```js > obj = { > 42: function() {} > }; > ``` > > I appreciate your taking the time to post those examples. I take it > these are the objections you referred to in [July > 2015](https://esdiscuss.org/topic/name-anonymous-functions-on-property- > assignments#content-7) > as why consensus couldn't be reached for this form? > > Thanks again, > > -- T.J. > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

