Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Below is my code for object array in JavaScript:

var lineChartData = [{

            date: new Date(2009, 10, 2),

            value: 5

        }, {

            date: new Date(2009, 10, 25),

            value: 30

        }, {

            date: new Date(2009, 10, 26),

            value: 72,

            customBullet: "images/redstar.png"

        }];

Can anyone tell me how to  print the object array in the browser window, similar to print_r function in PHP?

1 Answer

0 votes
by (19.7k points)

You can stringify your object and assign it to the innerHTML of an element of your choice.

var lineChartData = [{

            date: new Date(2009, 10, 2),

            value: 5

        }, {

            date: new Date(2009, 10, 25),

            value: 30

        }, {

            date: new Date(2009, 10, 26),

            value: 72,

            customBullet: "images/redstar.png"

        }];

document.getElementById("whereToPrint").innerHTML = JSON.stringify(lineChartData, null, 4);

Interested in Java? Check out this Java tutorial by Intellipaat.  

Related questions

Browse Categories

...