Languages
[Edit]
EN

JavaScript - convert string to number

7 points
Created by:
Wiktor-Sribiew
710

In this article, we would like to show you how to convert string to number using JavaScript.

1. Dedicated functions

  1. JavaScript - how to convert string to integer number?
  2. JavaScript - how to convert string to float number?

2. Number function examples

2.1. String with integer number example

// ONLINE-RUNNER:browser;

var text = '123';
var number = Number(text);

console.log(number === 123);

2.2. String with float number example

// ONLINE-RUNNER:browser;

var text = '3.13';
var number = Number(text);

console.log(number === 3.13);

Alternative titles

  1. JavaScript - how to convert string to number?
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript - string conversion

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

â€ïžđŸ’» 🙂

Join