Partially-applied (or curried) functions could obfuscate the JavaScript stack trace
Thai Pangsakulyanont
3873

That ‘nameIs’ function is wild. I’ve ‘translated’ it into English but still can’t work out how it works. Can you explain? Especially the return value (and subsequent array access, or whatever is going on).

function nameIs(name, f) {
const key = `----> ${name}`;
return {
[key] () { return f.apply(this, arguments); }
}[key]
}

Yabai.

Like what you read? Give Anthony Good a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.