Javascript Gotchas

By | Jan 9, 2015

In most of the scenario we are looking for jquery plugin or 3rd party library for even simple stuffs that can easily be done using javascript. In this post, I will list down the simple javascript ways to do the stuffs so that we don't need to overload our applications with so many plugins.

JSON to Pretty Print JSON string

var emp = {name:'Anurag Gandhi', 'email':'foo@bar.com', age: 30, address:{ line1: '1st  street', city:'bangalore', 'country': 'India'}};
var str = JSON.stringify(obj, undefined, 4); // indentation level = 2

 

3 thoughts on “Javascript Gotchas

Leave a Reply

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