News for hackers. Stuff that matters.
Re:Greppability is an underrated code metric by mrighele on Tuesday September 03, 2024 @08:31AM (#41434321)
Interesting, it seems that the javascript runtime is smart enough detect this pattern and actually create a named function (I tried Chrome and Node.js)

    const foo = () => {}
    console.log( foo.name );
actually outputs 'foo', and not the empty string that I was expecting.

   const test = () => ( () => {} );
   const foo = test();
   console.log( foo.name );
outputs the empty string.

Is this behavior required by the standard ?

Re:Greppability is an underrated code metric by svieira on Tuesday September 03, 2024 @09:00AM (#41434536)
Re:Greppability is an underrated code metric by Izkata on Tuesday September 03, 2024 @01:04PM (#41436891)
You're probably remembering how it used to work. This is the example I remember from way back that we shouldn't use because (aside from being unnecessary and weird) this function wouldn't have a name in stack traces:

  var foo = function() {};
Except nowadays it too does have the name "foo".