4

Are performance effects when using JavaScript anonymous functions also applicable for node.js programs when most of the code in the wild is network/http oriented and processing requests, connections and such is mostly done through anonymous functions? Can this lead to potential performance drop during higher traffic load?

1 Answer 1

6

It really depends on your code, and without measuring it, you cannot know. But in general, you can be quite sure that the time spent waiting for I/O significantly outweighs the time spent creating callback functions for handling these I/O events. Therefore, in normal scenarios there is probably no significant (or even no measurable) gain in optimizing the creation of callbacks. There are likely other areas where it is easier to gain performance and to find them you have to profile your code.

Sign up to request clarification or add additional context in comments.

1 Comment

A useful answer. However, aiming towards separately declared (anonymous or non) functions can be a readability aid, whether or not the performance impacts are significant: overusing callbacks that are anonymously declared inline with whatever invokes them can lead to less-legible, heavily nested code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.