Answers for "how to string with number in javascript"

46

string to number javascript

// Method - 1 ### parseInt() ###
var text = "42px";
var integer = parseInt(text, 10);
// returns 42

// Method - 2 ### parseFloat() ###
var text = "3.14someRandomStuff";
var pointNum = parseFloat(text);
// returns 3.14

// Method - 3 ### Number() ###
Number("123"); // returns 123
Number("12.3"); // returns 12.3
Number("3.14someRandomStuff"); // returns NaN
Number("42px"); // returns NaN
Posted by: Guest on February-24-2021
8

make number string js

var num = 15;
var n = num.toString();
Posted by: Guest on September-02-2020

Code answers related to "how to string with number in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language