Created
September 1, 2015 00:49
-
-
Save rwaldron/a6c1607132b03ba078c7 to your computer and use it in GitHub Desktop.
Endianness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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