• most JS interpreters scan ahead for new function definitions within its current scope

      console.log("level 1");
      return lvl2();
      function lvl2(){
        console.log("level 2");

    Espruino's JS does not

  • Yes, I'm aware of that. It's a side-effect of the way Espruino executes code as it parses.

    Espruino does have the ability to work in a two-pass mode where this code would then work, but doing two passes really hurts execution speed so the decision was made not to turn the functionality on.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

functions defined in scope before calling is not defined

Posted by Avatar for bmatusiak @bmatusiak