(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 ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23>  <24>  <25
Link to this page: http://www.vb-net.com/JavascriptES6/TA13.htm
<TAGS>  <ARTICLES>  <FRONT>  <CORE>  <MVC>  <ASP>  <NET>  <DATA>  <TASK>  <XML>  <KIOSK>  <NOTES>  <SQL>  <LINUX>  <MONO>  <FREEWARE>  <DOCS> <TRAVELS> <FLOWERS> <RESUME> < THANKS ME>