I'm using a service to load my form data into an array in my angular2 app. The data is stored like this:
arr = []
arr.push({title:name})
When I do a console.log(arr)
, it is shown as Object. What I need is to see it
as [ { 'title':name } ]
. How can I achieve that?
you may use below,
JSON.stringify({ data: arr}, null, 4);
this will nicely format your data with indentation.
To print out readable information. You can use console.table()
which is much easier to read than JSON:
console.table(data);
This function takes one mandatory argument data, which must be an array or an object, and one additional optional parameter columns.
It logs data as a table. Each element in the array (or enumerable property if data is an object) will be a row in the table
Example:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With