Skip to content

@pmun/utils / randomInt

Function: randomInt() ​

ts
function randomInt(min, max): number;

生成指定范围内的随机整数(包含边界值)

Parameters ​

min ​

number

最小值(包含)

max ​

number

最大值(包含)

Returns ​

number

指定范围内的随机整数

Example ​

ts
randomInt(1, 10) // 返回 1 到 10 之间的随机整数,包括 1 和 10
randomInt(0, 1) // 返回 0 或 1
randomInt(5, 5) // 总是返回 5