stable and es6 code version produce different output #1445
Replies: 6 comments
-
Posted at 2021-01-04 by @allObjects What if you declare b in line 22 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-04 by @MaBecker
No, but a mix version of es6 and stable like this works:
I guess it's a special constellation of arrow function usage that causes the interpreter to fail. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-05 by @gfwilliams Thanks - that's interesting... Unlike normal functions, Arrow functions store the value of In that code, it looks like they're expecting Actually MDN has this to say: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#Use_of_the_new_operator
So it looks like the code is invalid. And if you try and run even a small snippert in Node.js, it fails:
Where did the code come from? If anything Espruino's failing here appears to be not producing an error when |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-05 by @MaBecker
Not at all! Reason: There is no this in arrow functions - that‘s all. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-05 by @MaBecker
From trying to shrink js code. Your code snippet does not produce an error, that made me stumble over this and thinking there is a special implementation of arrow functions. copy & paste WebIDE left side:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-05 by @allObjects @MaBecker/@gfwilliams, did not notice that a() was defined as 'classical'/regular function but b() was defined as arrow function. That was by the way the reason that I did not change the TMQ regular - constructor - function in tinyMQTT to an arrow function, but everything else I did convert. I was first even concerned to change the prototype functions into arrow functions... but since they do not use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2021-01-04 by @MaBecker
Is there something missing in the es6 version to make it work?
board information:
code:
output:
Beta Was this translation helpful? Give feedback.
All reactions