Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Converting a String into a Number in Javascript

// Converting a String into a Number in Javascript
// Longhand:
const num1 = parseInt("100");
const num2 =  parseFloat("100.01");
console.log(num1);
console.log(num2);

// Shorthand:
const num3 = +"100"; // converts to int data type
const num4 =  +"100.01"; // converts to float data type
console.log(num3);
console.log(num4);
 
PREVIOUS NEXT
Tagged: #Converting #String #Number #Javascript
ADD COMMENT
Topic
Name
4+4 =