Get the latest tech news

Exploring Randomness in JavaScript


Ben Nadel compares the randomness of Math.random() to crypto.getRandomValues() in JavaScript.

To this end, I want to try generating some random visual elements using both Math.random() and crypto.getRandomValues() to see if one of the methods feels substantively different. With these two methods in place, I can then assign one of them to a randFloat() reference which can be used to seamless generate random values along a given range using either algorithm interchangeably: When the component is initialized, it will populate these two refs with random values using the methods, fillCanvas() and fillList(), respectively.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of javascript

javascript

Photo of randomness

randomness

Related news:

News photo

Create HTML/ZIP/PNG Polyglot Files in JavaScript

News photo

Google Sheets ported its calculation worker from JavaScript to WasmGC

News photo

The many faces of undefined in JavaScript