You are reading a single comment by @Frida and its replies. Click here to read the full conversation.
  • With the same code, I have different output on pico and esp8266.

    Which one is correct?
    I think it is esp8266, but I may be wrong.

    esp8266
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v85.1127 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 512KB:256/256, manuf 0xc8 chip 0x4013
    >echo(0);
    oldtime  1462372910.64224791526
    newtime  1462372911.01720309257
    diftime  0.37495517730
    =undefined
    >
    
     
    pico
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v85 Copyright 2016 G.Williams
    >echo(0);
    oldtime  1462373548.05334663391
    newtime  undefined
    Uncaught ReferenceError: "newtime" is not defined
     at line 1 col 25
    console.log('newtime ', newtime);
                            ^
    diftime  NaN
    Uncaught ReferenceError: "newtime" is not defined
     at line 1 col 33
    console.log('diftime ', newtime-oldtime);
                                    ^
    =undefined
    >
    
    

    code:

    oldtime = getTime();
    setTimeout(function() {
      newtime = getTime();
    },160);
    
    console.log('oldtime ', oldtime);
    console.log('newtime ', newtime);
    console.log('diftime ', newtime-oldtime);
    
    
About

Avatar for Frida @Frida started