JS: Number.parseFloat (string to number)

By Xah Lee. Date: . Last updated: .

parseFloat

Number.parseFloat(string)

Convert a string to a decimal number.

console.assert(
 parseFloat("324") === 324,
);

console.assert(
 parseFloat("1.24") === 1.24,
);

Global Object

Number.parseFloat is the same as the "parseFloat" of the Global Object.

console.assert(Number.parseFloat === globalThis.parseFloat);