Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

closure and scope javascript

function outerFunction () {
  const outer = `I'm the outer function!`

  function innerFunction() {
    const inner = `I'm the inner function!`
    console.log(outer) // I'm the outer function!
  }

  console.log(inner) // Error, inner is not defined
}
Source by css-tricks.com #
 
PREVIOUS NEXT
Tagged: #closure #scope #javascript
ADD COMMENT
Topic
Name
3+1 =