Answers for "javascript closure stack overflow"

0

javascript closure stack overflow

function foo() {
  const secret = Math.trunc(Math.random()*100)
  return function inner() {
    console.log(`The secret number is ${secret}.`)
  }
}
const f = foo() // `secret` is not directly accessible from outside `foo`
f() // The only way to retrieve `secret`, is to invoke `f`
Posted by: Guest on May-23-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language