Avatar for jrh

jrh

Member since Aug 2019 • Last active Oct 2019
  • 1 conversations
  • 3 comments

jrh:
Chicago, IL USA

Most recent activity

  • in JavaScript
    Avatar for jrh

    I see the workaround works in node as well. Thanks for the tip!

    $ node
    > function foo() {
    ... for (var i = 0; i < arguments.length; i++) {
    ..... console.log(arguments[i]);
    ..... }
    ... }
    undefined
    > foo(1,2)
    1
    2
    undefined
    > foo(100)
    100
    undefined
    > foo(1,2,3,4,5)
    1
    2
    3
    4
    5
    undefined
    >
    
  • in JavaScript
    Avatar for jrh

    I was testing espruino on the Linux command line (while waiting for my boards to be shipped) and ran across this error. Is this a bug, or a feature?

    $ espruino
    Interactive mode.
    Size of JsVar is now 32 bytes
    Size of JsVarRef is now 4 bytes
    Added SIGINT hook
    Added SIGHUP hook
    Added SIGTERM hook
    
     ____                 _ 
    |  __|___ ___ ___ _ _|_|___ ___ 
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v04.8 (c) 2019 G.Williams
    
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    
    >function foo(x,y) {
    :for (var i = 0; i < arguments.length; i++) {
    :console.log(arguments[i]);
    :}
    :}
    =function (x,y) { ... }
    >foo(1,2)
    1
    2
    =undefined
    >foo(100)
    100
    Uncaught ReferenceError: "1" is not defined
     at line 2 col 24
    console.log(arguments[i]);
                           ^
    in function "foo" called from line 1 col 8
    foo(100)
           ^
    >quit()
    =undefined
    >
    

    The source was cloned from github and compiled on Ubuntu 16.04.6 LTS. I got the same error on an OS X build as well. It was built with the following commands:

    export BOARD=LINUX
    source ./scripts/provision.sh $BOARD
     make clean && RELEASE=1 BOARD=$BOARD make
    

    I saw this post Functions with unknown amount of args. but I didn't get the same results.

Actions