Thanks - that's interesting... Unlike normal functions, Arrow functions store the value of this when they are defined.
In that code, it looks like they're expecting this to be something else though. Maybe ES6 defines some magic case where if you do new ArrowFunction, this is no longer what it's expected to be what it is in every other case.
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.
Thanks - that's interesting... Unlike normal functions, Arrow functions store the value of
this
when they are defined.In that code, it looks like they're expecting
this
to be something else though. Maybe ES6 defines some magic case where if you donew ArrowFunction
,this
is no longer what it's expected to be what it is in every other case.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
new ArrowFn
is used.