Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

what is a closure in javascript

// A Closure gives you access to an outer function's scope from an inner function.
// Example
function myNameIs(name) {
  return function(){
  	console.log('Hi my name is ' + name);
  }
}

let maxine = myNameIs('Maxine');
let amber = myNameIs('Amber');

maxine();
amber();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #closure #javascript
ADD COMMENT
Topic
Name
3+9 =