-
• #2
Additionally, are there any performance differences between
==
and===
? -
• #3
var/let
are handled the same in Espruino (that's something that will change at some point though).c=3
creates a GLOBAL variable, even if you're in a function.There shouldn't be a big performance different either way between == and ===.
-
• #4
What about
const
? -
• #5
const x = 1;
After assignment x can not be changed. Though I think you can get away with it in an app if you are just uploading an app file to storage. If you try do a pull request the automated build will kick out any assigments of x after the initial assignment.
-
• #6
It's best to look at an actual JS reference:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/constBut in Espruino,
var
,let
andconst
are treated the same. Eventually this will change but right now you can assign to aconst
, although as @HughB says it's a good idea to use as the linter can still check it and throw up errors -
• #7
Yeah I understand how they work in other Javascript environments, I was curious about espruino specifically.
As long as there aren't any disadvantages to using let and const in espruino I'll continue to use them since that is what I usually use in JavaScript these days.
-
• #8
The only disadvantage is that because right now Espruino doesn't treat
let
as 'scoped', if you minify the code, occasionally the minifier can make optimisations that break the code :( -
• #9
Okay, that's good to know. Thanks
Hi, I was wondering if there is any difference in the following lines when in Bangle.js: