That ‘nameIs’ function is wild.
Anthony Good

When you create a method using ES6 method shorthand, the runtime will set the generated function’s name from the property’s name.

const key = 'hello'
const obj = {
[key] () {
throw new Error('ヤバい!!')
const fn = obj[key]
// => 'hello'

(This behavior is defined in ES2015 Specification §14.3.9.)

This means when the function throws an error, the stack trace should include the function name hello in the stack trace:

Uncaught Error: ヤバい!!
at hello (<anonymous>:4:11)
at <anonymous>:1:1

This is how we create a named function with a dynamic name.

Unfortunately, Firefox does not respect this name when generating the stack trace… It only works in V8 (Chrome and Node).

So, the 名は function takes a name , a function f, and returns a named function that just forwards the arguments to f.

Hope this helps!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.