Skip to content

About the author of Daydream Drift

Tomasz Niezgoda (LinkedIn/tomaszniezgoda & GitHub/tniezg) is the author of this blog. It contains original content written with care.

Please link back to this website when referencing any of the materials.

Author:

Converting String To Number In JavaScript

Published

Add + at the beginning of a variable to convert it into a Number. For example:

const numberInsideAString = "1231.12";
console.log(+numberInsideAString);

For a detailed explanation of how + converts various JavaScript types, see Cast to Number in Javascript using the Unary (+) Operator