Math.random()
Math.random() is a JavaScript method in the Math category. Returns a random number between 0 (inclusive) and 1 (exclusive). The syntax is Math.random(). A typical example: Math.random() // 0.123456789. Another practical use — Random integer: function randomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min } console.log(randomInt(1, 10)) // random 1-10 The TypeScript signature is (): number. A close sibling is Math.abs(), which returns the absolute value of a number. A close sibling is Math.ceil(), which rounds up to the nearest integer. A close sibling is Math.floor(), which rounds down to the nearest integer. A close sibling is Math.round(), which rounds to the nearest integer. More about this category: Math functions for calculations — random, round, sqrt, floor, and more. Related Math methods: Math.abs(), Math.ceil(), Math.floor(), Math.round(), Math.trunc(), Math.max(), Math.min(), Math.sqrt(). This page is part of the free JS Reference documentation covering 1027+ methods, each with syntax, parameters, return values, examples, and common pitfalls.