Actually E.toUint8Array seems to make a copy, just tried in emulator
E.toUint8Array
>var h=E.toFlatString("Hello") ="Hello" >var hb=E.toArrayBuffer(h) =new Uint8Array([72, 101, 108, 108, 111]).buffer >var hu=Uint8Array(hb) =new Uint8Array([72, 101, 108, 108, 111]) >var hu2=E.toUint8Array(h) =new Uint8Array([72, 101, 108, 108, 111]) >E.getAddressOf(hu,true) =179852 >E.getAddressOf(hb,true) =179852 >E.getAddressOf(h,true) =179852 >E.getAddressOf(hu2,true) =180006 >var hu3=E.toUint8Array(hb) =new Uint8Array([72, 101, 108, 108, 111]) >E.getAddressOf(hu3,true) =180300
So hu2 and hu3 made by E.toUint8Array makes new array from same buffer. Others work as expected.
@fanoush started
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.
Actually
E.toUint8Array
seems to make a copy, just tried in emulatorSo hu2 and hu3 made by
E.toUint8Array
makes new array from same buffer. Others work as expected.