Hi,
I am not JS expert, but I think it all comes down to the way the Web IDE handles your script as @fanoush already mentioned. The code gets executed line by line as it gets uploaded. You can clearly see this when you hit upload, then change to the left side of the editor and hit the up arrow button to show the executed command history.
You see that the nope now is being executed last, even after printing the result of the function. Maybe you can run your other tests in a similar fashion and it will clear things up for you.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
I am not JS expert, but I think it all comes down to the way the Web IDE handles your script as @fanoush already mentioned. The code gets executed line by line as it gets uploaded. You can clearly see this when you hit upload, then change to the left side of the editor and hit the up arrow button to show the executed command history.
Here is your first example with added timestamps:
Output:
You can see that nope was written earlier than the yeps. Now let's wrap this in a function and call the function to execute it as a single block:
Output:
You see that the nope now is being executed last, even after printing the result of the function. Maybe you can run your other tests in a similar fashion and it will clear things up for you.