As I read in Internets, array.length can cut array to size. I need this to save only 100 last readings. But using lenght can, I think, cause some memory issues.
a = new Array();
a = [1, 2, 3, 4, 5, 6];
>[ 1, 2, 3, 4, 5, 6 ]
=[ 1, 2, 3, 4, 5, 6 ]
>a.length = 2
=[ 1, 2, 3, 4, 5, 6, "length": 2 ]
I can get a real array size only before trying to cut it.
I'm afraid Espruino doesn't support setting the array length - however it's trivial to work around.
You can use either of:
Also, if you're after storing a whole lot of readings, maybe look at using Uint8Array/etc as they'll be vastly more efficient when storing large amounts of data.
Thank you for support and all answers, I'm happy with it!
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem