function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sandhya K 10Sandhya K 10 

JavaScript Closure

What is Javascript Closure ? How can we use that in a VF page ? An example of the same would be very helpful . 
NagendraNagendra (Salesforce Developers) 
Hi Sandhya,

A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain. The closure has three scope chains: it has access to its own scope (variables defined between its curly brackets), it has access to the outer function’s variables, and it has access to the global variables.

The inner function has access not only to the outer function’s variables but also to the outer function’s parameters. Note that the inner function cannot call the outer function’s arguments object, however, even though it can call the outer function’s parameters directly.

Please check with below links which provide additional information. Hope this helps.

Thanks,
Nagendra.