# JavaScript Math Snippets

The JavaScript snippet collection contains a wide variety of ES6 helper functions. It includes helpers for dealing with primitives, arrays and objects, as well as algorithms, DOM manipulation functions and Node.js utilities.

• ### Round number to given precision

Rounds a number to a specified amount of digits.

JavaScript, Math · Oct 22, 2020

• ### Validate number

Checks if the given value is a number.

JavaScript, Math · Oct 22, 2020

• ### Clamp number

Clamps `num` within the inclusive range specified by the boundary values `a` and `b`.

JavaScript, Math · Oct 22, 2020

• ### Copy sign to number

Returns the absolute value of the first number, but the sign of the second.

JavaScript, Math · Oct 7, 2020

• ### Number in range

Checks if the given number falls within the given range.

JavaScript, Math · Nov 1, 2020

• ### Random boolean value

Generates a random boolean value.

JavaScript, Math · Jan 20, 2021

• ### Value is number

Checks if the given argument is a number.

JavaScript, Type · Sep 15, 2020

• ### Logarithm in specific base

Calculates the logarithm of the given number in the given base.

JavaScript, Math · Oct 22, 2020

• ### Generate Gaussian random numbers

Generates Gaussian (normally distributed) random numbers.

JavaScript, Math · Apr 3, 2023

• ### Sum of numbers until n

Sums all the numbers between `1` and `n`.

JavaScript, Math · Oct 22, 2020

• ### Approximate number equality

Checks if two numbers are approximately equal to each other.

JavaScript, Math · Nov 1, 2020

• ### Convert between degrees and radians in JavaScript

JavaScript, Math · Sep 15, 2023

• ### Number is divisible

Checks if the first numeric argument is divisible by the second one.

JavaScript, Math · Sep 15, 2020

• ### Number is negative zero

Checks if the given value is equal to negative zero (`-0`).

JavaScript, Math · Oct 20, 2020

• ### Number is power of ten

Checks if the given number is a power of `10`.

JavaScript, Math · Jan 6, 2021

6