0

I am a newbie in NodeJS, my background is Swift.

When facing forEach, I wonder if it would create a reference cycle?

const array = [1, 3, 2, 4]
arrach.forEach(function(element) {
    doSomething(element)
})

function doSomething(number) {
    // ...
}

In Swift, the code above will create a reference cycle since the closure has referenced to a function in self, which is doSomething. Is this also a case in NodeJS?

Regards,

quanguyen
  • 1,443
  • 3
  • 17
  • 29

0 Answers0