top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is Closure and Hoisting?

+1 vote
296 views
What is Closure and Hoisting?
posted Jun 5, 2014 by Rajneesh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Closure:

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!)

Hoisting:

In Javascript, we have multiple var-statements in a function. All of these statements act as if they were declared at the top of the function. Hoisting is the act of moving the declarations to the top of the function.

answer Jun 6, 2014 by Vrije Mani Upadhyay
...