The toString() method returns a string representing an object.


Parse An Integer As String

In this example, we will use the toString method to parse an integer as a string.

const number = 123;
const numberAsString = number.toString();
// Result: "123"


Parse An Object As String

In this example, we will parse an object as a string. 

const carObject = {
  make: "Suzuki",
  model: "Swift",
};
const carObjectAsString = carObject.toString();
// Result: [object Object]