(ES6) ES6 (2016)

TypedArr (TA01)

   1:  import {intToHexArray, hexArrayToInt, byteArrayAsHex, numberToBinary} from "./TA%2300.js"
   2:  
   3:  const number1 = 12345;
   4:  const hexString1 = number1.toString(16); // Convert to hex
   5:  console.log(hexString1); // Output: "3039"
   6:  
   7:  const hexString2 = "3039";
   8:  const number2 = parseInt(hexString2, 16); // Convert hex to integer
   9:  console.log(number2);
  10:  
  11:  const hexArray1 = ["00", "00", "30", "39"];
  12:  const number3 = hexArrayToInt(hexArray1);
  13:  console.log(number3); // Output: 12345
  14:  
  15:  const buffer = new ArrayBuffer(4);
  16:  const view = new DataView(buffer);
  17:  view.setUint8(0, 0x00); // Most significant byte (MSB)
  18:  view.setUint8(1, 0x00);
  19:  view.setUint8(2, 0x30);
  20:  view.setUint8(3, 0x39); // Least significant byte (LSB)
  21:  
  22:  const hexArray = byteArrayAsHex(buffer);
  23:  console.log(hexArray); // Output: ["00", "00", "30", "39"]
  24:  
  25:  console.log(intToHexArray(12345)) //00110000 00111001
  26:  
  27:  
  28:  console.log(numberToBinary(12345))
  29:  
  30:  
  31:  
  32:  
  33:  
  34:  



3039
12345
12345
[ '00', '00', '30', '39' ]
[ '39', '30', '00', '00' ]
00110000 00111001





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/TA01.htm
<TAGS>  <ARTICLES>  <FRONT>  <CORE>  <MVC>  <ASP>  <NET>  <DATA>  <TASK>  <XML>  <KIOSK>  <NOTES>  <SQL>  <LINUX>  <MONO>  <FREEWARE>  <DOCS> <TRAVELS> <FLOWERS> <RESUME> < THANKS ME>