• There is no difference between the two types at the moment...

    But:

    function a() {
      function b() { foo(); }
      doSomething();
    }
    

    What happens now

    • A variable for a is created
    • Inside it, a variable >cod it set to the function's code.

    Result:

    var a = { ">cod" : "{\n  function b() { foo(); }\n  doSomething();\n}" };
    

    What will happen in a later version of Espruino

    • A variable for a is created
    • The function's code is parsed, and the Espruino recursively does the same thing on any functions inside the current one
    • Inside it, a variable >cod it set to the function's code, minus any functions defined inside it.

    Result:

    var a = { 
     "b": { ">cod" : "{ foo(); }"} 
     ">cod" : "{\n  doSomething();\n}" 
    };
    

    Does that make more sense? If you used var b = function() { ... } exactly the same thing would happen in the future as happens now (what's described above).

About

Avatar for Gordon @Gordon started