Home  /  Questions  /  Question

139   96.7
Oct 22, 2013

In JavaScript, how exactly are scope and closure related?

Actually, I know that scope and closure are related, but I am not clear exactly how or in what sense. 

From what I understand scope refers to the visibility of variables (for example inside a function).   
And a closure defines the boundary of this visibility.   

Is this correct?  If so, there is a global scope, but is there also a global closure?
Could someone shed some light and post the simplest possible code demonstrating these concepts?