Skip to content

JavaScript object toString() | Method

  • by

Use JavaScript object toString() method to get an object as a string. This method returns a string representing the object.


The toString() method does not take any parameters.

JavaScript object toString

Simple example code.

<!DOCTYPE html>
  <script >

    let num = 100;

    var Student = { Name: 'John',  RollNo: '234' }


JavaScript object toString

Converting an object to a string

It recommends using JSON.stringify, which converts the set of the variables in the object to a JSON string. Most modern browsers support this method natively, but for those that don’t, you can include a JS version:

var obj = {
  name: 'myObj'


Do comment if you have any doubts or suggestions on this JS object method topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *