(ES6) ES6 (2016)

TypedArr (TA13)

   1:  const buffer = new ArrayBuffer(2);
   2:  const view = new DataView(buffer);
   3:  view.setUint16(0, 0x1234, true); // true for Little-endian
   4:  
   5:  const byteArray = new Uint8Array(buffer);
   6:  const isLittleEndian = byteArray[0] === 0x34 && byteArray[1] === 0x12;
   7:  console.log(isLittleEndian ? "Little-endian" : "Big-endian");



Check the Endianness of the System

Little-endian


    Little-endian: Most modern systems (e.g., x86, x64, ARM) use little-endian architecture. In little-endian, the least significant byte (LSB) is stored at the lowest memory address.
    Big-endian: Some older systems (e.g., PowerPC, SPARC) use big-endian architecture. In big-endian, the most significant byte (MSB) is stored at the lowest memory address.

    The DataView API allows you to explicitly specify the endianness when reading or writing multi-byte values. By default, it uses the platform's native endianness, but you can override this behavior.





TypedArr context:






ES6 context:




Binary context:



Comments ( )
Link to this page: http://www.vb-net.com/JavascriptES6/TA13.htm
< THANKS ME>