• Hello, I did not find any reliable information on the website. Which ECMAScript Version is interpreted by Espruino? Is it ECMAScript 6 (also known as ECMAScript 2015) or a newer version?

  • Just to clarify this:

    Espruino isn't 100% of any JavaScript spec (for instance no Regular Expressions at the moment), but it's pretty much ES5, with some ES6 features (arrow functions, template strings, binary literals, forEach/etc on ArrayBuffers) where it makes sense.

    Functionality gets added all the time though - see http://www.espruino.com/Features for an up to date list

  • @Gordon, is there a lint-like thing for Espruino that a JS source can be pitted against and will return 'passed' or 'failed'?

  • No, afraid not. I've tweaked the Espruino IDE linter a little, but it's not 100%.

    Also some devices like ESP8266 cut out features like arrow functions to save some flash memory I believe.

  • Do arrow functions save more memory than normal functions? at least on the ESP8266??? @Gordon

  • Do arrow functions save more memory than normal functions?

    Yes and no - they use less characters so that's less bytes for the actual code. However when they're defined they often use 2 more variables since they have to store this for each function.

    If you're using the pretokenise flag then the function keyword gets squished down so a lot of that benefit disappears.

    The actual memory used should be the same on all platforms though.

  • this pretokenise flag is still effective just for code in RAM,right? Recently there appeared some beta flag "Pretokenise code before upload (BETA)" in web IDE - minification section. I tried it but it doesn't look like it did change anything to code size stored in flash. Is it supposed to work with flash memory? Couldn't espruino pretokenize the file while saving it into storage .bootcde file? if I processed the file on the device and replaced just all occurrences of 'function' or 'this' (which may be the longest and most frequent ones) by correct byte token would it work including the rest of file which is not tokenised?

  • this pretokenise flag is still effective just for code in RAM,right?

    The flag itself is, yes.

    However the Pretokenise code before upload (BETA) option in the IDE should pretokenise the code in the IDE.

    I just looked into this and annoyingly it does it only when uploading to RAM, which kind of defies the point. The issue was just to do with the ordering of the various transforms that are applied to the code and I've now fixed it, but right now it's only live on espruino.com/ide (you'll have to ensure you refresh the page to pick the change up)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

What version of JS does Espruno implement? (ES5/ES6)

Posted by Avatar for MobiTech @MobiTech