2
process.on('an event', function () {
    setTimeOut(function onTimeOut() {

        // ... code

    }, 5000)
})  

Hi friends! I have two question, please advise me.

  1. Will the named callback function onTimeOut stored at Global scope and skipped by GC?
  2. If it is stored at local scope, it will re-created every time the event invoked (tagged to GC), right?

1 Answer 1

2
  1. No, it is stored in the closest scope just like any other variable/value. Additionally, the name will only be referenceable inside the body of that function.
  2. Yes, a new callback function will be created every time the an event event fires.
Sign up to request clarification or add additional context in comments.

Comments

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.