Default parameter

Posted on
  • I can upload this feature, but it does not give me any default values.
    Will it work in Espruino?

    function dd (tmp, dur = 100, opt = 50) {
    // if (tmp === undefined) tmp = 200;
    // if (dur === undefined) dur = 100;
    // if (opt === undefined) opt = 0;
       console.log (tmp, dur, opt);
    }
    
    /*
    >dd()
    undefined undefined undefined
    =undefined
    
    >dd(10,20,30)
    10 20 30
    =undefined
    */
    
  • This is a ES2015 feature and sadly not supported yet.

  • As @PaddeK says, I'm afraid it's not implemented at the moment.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Default parameter

Posted by Avatar for Frida @Frida

Actions