Last active
June 27, 2021 00:37
-
-
Save chop0/d65368c0f043e455feffeaf566917416 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lemonthink() { | |
let buf = new ArrayBuffer(4); | |
let lemon = new Int32Array(buf); | |
let think = new Float32Array(buf); | |
lemon[0] = 0x7F800001; // A NaN that's not the normal JS NaN | |
think[0] = think[0]; // When interpreted, JS sees the (different to normal) NaN and replaces it with a normal NaN. Compiled JS doesn't modify the value. | |
return lemon[0]; | |
} | |
console.log(lemonthink()); // 0x7fc00001, 2143289345 | |
for(let i = 0; i < 20000; i++) lemonthink(); | |
console.log(lemonthink()); // 0x7f800001, 2139095041 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment