Hacker News new | ask | show | jobs
by dalbin 3569 days ago
Are there people working on JS Engine ?

I would like to have more info on why JS create unnecessary new function objects if there are only called in the parent function scope.

1 comments

The author answers this in the comments [1].

> Functions are also first class objects with observable identity, just like any other object. Identity can be observed in many ways, for example by doing an equality comparison or assigning a property. In the first example optimization is indeed possible as it's easy to see that the functions cannot be used for their identity. Optimizations have maintenance costs however and if similar simple scenarios are not common in the real world the optimization might not be worth implementing.

[1]: https://reaktor.com/blog/javascript-performance-fundamentals...