Answers for "Function declaration in conditionals"

0

Function declaration in conditionals

(function() {
  'use strict';
  if (true) {
    function ok() {
      return 'true ok';
    }
  } else {
    function ok() {
      return 'false ok';
    }
  }
  console.log(typeof ok === 'undefined'); // => true
  console.log(ok()); // Throws "ReferenceError: ok is not defined"
})();
Posted by: Guest on September-17-2021

Code answers related to "Function declaration in conditionals"

Code answers related to "Javascript"

Browse Popular Code Answers by Language