How to parse a string in JavaScript?

Javascript Faysal Shuvo

Problem: 

I am learning JavaScript. I am at a beginner level. I want to know how can I parse something in JavaScript. 

In this article, we are going to learn how to parse a string in JavaScript?


Solution: 

You have a variable that contains a number. 

const exampleNumber = 5767;

if you check its type it will return you the number

console.log(typeof exampleNumber)
// number

To parse it to a string we can use toString()

const str = exampleNumber.toString()
console.log(typeof str)
// string

This way you can parse any value into a string.


Hope this solves your problem. If you have any more questions comment below.