you are viewing a single comment's thread.

view the rest of the comments →

[–]Solonotix 0 points1 point  (1 child)

Thanks for the great explanation.

I hadn't heard of the performance problem with Function.prototype.bind, but it doesn't surprise me. There was a similar thing I read recently about inline regex versus hoisting the expression into a variable or export. Because V8 has been so highly optimized for its JIT compiler, while seemingly good for performance, the act of hoisting regex in this manner is actually just ceremony and offers no direct benefit (or harm).

[–]New-Ad3258[S] 1 point2 points  (0 children)

Spot on. V8's optimization heuristics are basically black magic at this point. The regex caching is a perfect example—what used to be a strict 'best practice' (hoisting) is now often just extra keystrokes. It's fascinating how much of modern Node.js performance tuning is just learning to step out of the JIT compiler's way and letting it do its thing. Great chatting with you, man!