Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print all the properties of the object in javascript? [duplicate]

var object = { name: 'Harry', age: '25', sex: 'male'...... n};

This object has 'n' number of properties which I don't know and I would like to print these whole properties.

like image 432
SAI KRISHNA Avatar asked Nov 28 '22 13:11

SAI KRISHNA


1 Answers

There are heaps of solutions from a quick Google, a recomended result is; Print content of JavaScript object?

console.log(JSON.stringify(object, null, 4));

The second argument alters the contents of the string before returning it. The third argument specifies how many spaces to use as white space for readability.

like image 73
Florian Suess Avatar answered Dec 20 '22 23:12

Florian Suess