Skip to content

Instantly share code, notes, and snippets.

@rwaldron
Created September 1, 2015 00:49
Show Gist options
  • Save rwaldron/a6c1607132b03ba078c7 to your computer and use it in GitHub Desktop.
Save rwaldron/a6c1607132b03ba078c7 to your computer and use it in GitHub Desktop.
Endianness
function endian() {
var a32 = new Uint32Array([0x12345678]);
var a8 = new Uint8Array(a32.buffer);
return a8[1] === 0x12 && a8[2] === 0x78 ? 'MIDDLE' :
(a8[0] === 0x12 ? 'BIG' : 'LITTLE');
}
console.log(endian())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment