Anonymous contributor1 contribution
Published Oct 31, 2022
Contribute to Docs
.toString() method returns a string representation of a given value or object.
.toString() method takes no parameters.
Note: This method can be called on numbers, arrays, and objects.
The following example demonstrates the
// Assigning constant to integer valueconst myNum = 3;// Using .toString() method to get its string valueconst str = myNum.toString();console.log('Value of str variable is', str);// Using typeof operator to show string value was returnedconsole.log('Type of str variable is', typeof str);
This will produce the following output:
Value of str variable is 3Type of str variable is string
- Anonymous contributorAnonymous contributor1 contribution
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Computer ScienceLooking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
Includes 6 Courses
With Professional Certification