Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavaScripttyped arrays and ArrayBufferSingle-choice MCQ

On a little-endian machine, why do a DataView write and a Uint32Array write of the same value produce different byte layouts in the underlying buffer?

const ab = new ArrayBuffer(4); new DataView(ab).setUint32(0, 0x01020304); const be = [...new Uint8Array(ab)]; const u32 = new Uint32Array(1); u32[0] = 0x01020304; const native = [...new Uint8Array(u32.buffer)]; console.log(be, native);