DEV Community

Discussion on: 7 JavaScript ES2020 Features You Should Try

 
lexlohr profile image
Alex Lohr

Before BigInt, there was asm.js (which automatically handled numbers that were floored with |0 in any operation as integers) and Typed arrays. But other than that, you're right.

Thread Thread
 
peerreynders profile image
peerreynders • Edited

automatically handled numbers that were floored with |0

> const value = -1.9;
  console.log(Math.floor(value));
  console.log(Math.trunc(value));
  console.log(value | 0);

  -2
  -1
  -1
Enter fullscreen mode Exit fullscreen mode

i.e. trunctated, not floored - and that tactic is limited to signed 32 bit values.

Interestingly enough Rescript adopted 32 bit signed integers while TypeScript never bothered with them.

TypedArray/ArrayBuffer/DataView are less about integers and more about a performant means of sharing/moving binary data between execution contexts.