You are reading a single comment by @DrAzzy and its replies. Click here to read the full conversation.
  • Yes. Simple Arrays (the ones you get with var x = [];) are 2 memory units per entry. Storing 1 byte per entry in them gives you ~2.5% memory efficiency.

    That's why you should avoid them whenever possible (at least if storing data directly in them), and use typed arrays (like Uint8Array ) or strings instead (and why I've been agitating for a way to make i2c.readFrom() return either a string or a Uint8Array http://forum.espruino.com/conversations/934 ). The downside is that typed arrays are of fixed length - you can't splice and dice them like simple arrays.

    I've been trying to do everything with typed arrays, unless the array is either tiny and not worth the size savings, or has to contain objects/arrays/strings/etc that obviously can't be put into a Uint8Array.

    In your case, why would you not just leave it as a string, and use charCodeAt() to get the values as you need them?

About

Avatar for DrAzzy @DrAzzy started