Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

javascript

How to convert int to a string JavaScript

Nouman Abbasi

The toString() method can be used to convert a number to a string in JavaScript.

Syntax

number.toString(radix)

Parameters:

  • radix: Optional; specifies the base to use to represent a numeric value; must be an integer between 2 and 36.

Code

The following returns the string representation of the number :

let number = 42;

let str = number.toString();

console.log(str, typeof(str));

RELATED TAGS

javascript

CONTRIBUTOR

Nouman Abbasi
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring