Answers for "what are javascript closures used for"

4

closure in javascript

function makeFunc() {
  var name = 'Mozilla';
  function displayName() {
    alert(name);
  }
  return displayName;
}

var myFunc = makeFunc();
myFunc();
Posted by: Guest on July-04-2020
0

syntax of closures

/*
{ (parameters) -> return type in
body
}
*/

var numbers = [1, 2, 3, 4]

var reversed = numbers.sorted(by: {(a: Int, b: Int) -> Bool in
    return a > b
})
Posted by: Guest on September-05-2021

Code answers related to "what are javascript closures used for"

Code answers related to "Javascript"

Browse Popular Code Answers by Language