John Portnov

John Portnov's blog

Thursday, January 21, 2010

JavaScript Closures

Javascript closures can cause memory leaks and should be used with care. Click here to learn more.

The pattern of public, private, and privileged members is possible because JavaScript has closures. What this means is that an inner function always has access to the vars and parameters of its outer function, even after the outer function has returned. There is no book currently available on JavaScript programming that shows how to exploit it.

For a good Javascript book click here.

Javascript closures:
  • a closure is the local variables for a function - kept alive after the function has returned, or
  • a closure is a stack-frame which is not deallocated when the function returns. (as if a 'stack-frame' were malloc'ed instead of being on the stack!)
Posted by portnovj

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • December (1)
  • March (1)
  • April (1)
  • March (1)
  • December (1)
  • March (1)
  • June (1)
  • January (10)
  • October (1)
  • May (5)
  • April (2)
  • March (1)
My photo
View my complete profile