• Building function's context (frame / scope) and its variables / scoped variables, every entry in the argument list of the function is a variable known to the that frame.

    I use the technique to pass less arguments than declared in the list of function arguments for multiple reasons.

    The simple one is optional arguments and check their presence in the function.

    The more elaborate one is to 'declare' local variable(s) without having to spend the space for the extra var v = ...; statement. In the realm of micro controllers with very limited (memory and computing) resources, this is very efficient... and it works also in the Browser JS. Don't know if it works in nodeJS, but assume it does...

    Comparing Espruino's JS w/ browser (and node) JS, this is a difference. I though do not see a reason why this cannot be fixed... I'm sure 'Espruino' knows when it runs out of passed arguments and set arguments and it's length accordingly... but it may need to store the declared variables somewhere else for its own housekeeping / frame management / usage 'count' / garbage collect...

    Arguments arguments is anyway something weird... it can be accessed like an array - from the syntax point of view (like [] is a 'variable getter') - but it does not 'understand' .forEach() or for (var e in arguments) { ... };. Chrome/chromium defines it as a 'Symbol.iterator'... which makes sense...

About

Avatar for allObjects @allObjects started