0以上1未満のランダムな浮動小数点数を返す
Math.random(); // e.g. 0.7234...
// 整数乱数(0〜9)
Math.floor(Math.random() * 10);
// 範囲 [min, max) の乱数
const rand = (min: number, max: number) =>
Math.floor(Math.random() * (max - min)) + min;
rand(1, 7); // サイコロ(1〜6)暗号学的に安全な乱数には crypto.getRandomValues()を使う。Math.random()は予測可能なため認証用途には不向き。