Rehman Shahid
What are JavaScript closures?
By Rehman Shahid in JavaScript on Jul 22 2017
  • Bidyasagar Mishra
    Aug, 2019 2

    closures are the primary mechanism used to enable data privacy. When you use closures for data privacy, the enclosed variables are only in scope within the containing (outer) function. You can’t get at the data from an outside scope except through the object’s privileged methods. In JavaScript, any exposed method defined within the closure scope is privileged.

    • 0
  • Neeraj Negi
    Oct, 2018 8

    In Javascript variable declared outside the function are injectable inside the function due to the closure. Below is a simple example of closure var a ='hey';function test(){console.log(a); }test()

    • 0
  • Lalit Raghav
    Aug, 2018 18

    function showName (firstName, lastName) {? var nameIntro = "Your name is ";// this inner function has access to the outer function's variables, including the parameter function makeFullName () {? return nameIntro + firstName + " " + lastName;? }return makeFullName ();? }?showName ("Michael", "Jackson"); // Your name is Michael Jackson?

    • 0
  • Lalit Raghav
    Aug, 2018 18

    function showName (firstName, lastName) {? var nameIntro = "Your name is ";// this inner function has access to the outer function's variables, including the parameter function makeFullName () {? return nameIntro + firstName + " " + lastName;? }return makeFullName ();? }?showName ("Michael", "Jackson"); // Your name is Michael Jackson?

    • 0
  • Lalit Raghav
    Aug, 2018 18

    http://javascriptissexy.com/understand-javascript-closures-with-ease/

    • 0
  • Lalit Raghav
    Aug, 2018 18

    http://javascriptissexy.com/understand-javascript-closures-with-ease/

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS