JavaScript: Convert String/Number

By Xah Lee. Date: . Last updated: .

String to Integer

Number.parseInt

String to Decimal Number

Number.parseFloat

Number to String

Number.prototype.toString

Note: JavaScript automatically convert number to string. Adding a string to number results string.

let x = 3 + "4";
console.log(x === "34");
console.log(typeof x === "string");

JavaScript String

JavaScript Number

βˆ‘ JS in Depth
XAH Β BUY NOW

JS in Depth

JS Obj Ref

DOM


JS in Depth

Basic Syntax

Value Types

Variable

String

Function

Property

Object and Inheritance

Array

Constructor/Class

Iterable 🌟

Misc