Languages
[Edit]
EN

JavaScript - how to convert string to number?

7 points
Created by:
JustMike
3593

In this article links to existing type conversion approaches has been collected.

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);

 

JavaScript - string conversion

Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join