javascriptfunctionclosures

Is it possible to implement non-local-returns in JavaScript besides Exceptions?


Can non-local-returns be implemented in JavaScript, so that you could write something like:

function some_function() {
  function some_other_function(value) {
   non-local-return true;
  }
  some_other_function();
  return false;
}

true === some_function();

where some_function would return true, then?


Solution

  • Quite simply, no.

    (similar question here: let-a-function-return-the-super-function)