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).
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
There is no difference between the two types at the moment...
But:
What happens now
a
is created>cod
it set to the function's code.Result:
What will happen in a later version of Espruino
a
is created>cod
it set to the function's code, minus any functions defined inside it.Result:
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).