(ES6) ES6 (2016)

TypedArr (TA06)

   1:  const hexString = "3039";
   2:  const int1 = parseInt(hexString, 16)
   3:  const float1 = parseFloat(hexString)  //float1 = 3039 !!!
   4:  const big1 = BigInt(int1);
   5:  const big2 = BigInt(`0x${hexString}`); // big1 = 12345n
   6:  const char1 = String.fromCharCode(int1);
   7:  const bool1 = Boolean(int1);
   8:  
   9:  console.log(hexString);
  10:  console.log(int1);
  11:  console.log(float1);
  12:  console.log(big1);
  13:  console.log(big2);
  14:  console.log(char1);
  15:  console.log(bool1);
  16:  
  17:  console.log(big1 == float1);
  18:  console.log(big1 === float1);
  19:  console.log(big1 == int1);  // true (loose equality, coerces BigInt to number)
  20:  console.log(big1 === int1);
  21:  console.log(big2 === int1);
  22:  console.log(int1 == float1);
  23:  console.log(bool1 === int1);
  24:  console.log(bool1 == int1);
  25:  console.log(float1 == int1.toString())
  26:  console.log(big1 == int1.toString()) // true
  27:  console.log(bool1== char1); // false (character string is not coerced to boolean)
  28:  
  29:  




3039
12345
3039
12345n
12345n
〹
true
false
false
true
false
false
false
false
false
false
true
fals





TypedArr context:






ES6 context:




Binary context:



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