• Parsing a variable of type "undefined" creates an error:

    function foo(x, y) {
      for (var i=0; i<arguments.length; i++) {
         console.log("i="+i);
         try { console.log("val="+arguments[i]); } catch (e) { console.log(e);}
      }
    }
    foo(undefined, 1, undefined, 2)
    
    i=0
    ReferenceError: ReferenceError: "0" is not defined
    i=1
    val=1
    i=2
    ReferenceError: ReferenceError: "2" is not defined
    i=3
    val=2
    =undefined
    

    So there are two bugs: arguments.length is not updated (documented https://www.espruino.com/Reference#l__global_arguments). arguments fails for undefined arguments (not documented).

About

Avatar for maze1980 @maze1980 started