Javascript Gotchas

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':'', age: 30, address:{ line1: '1st  street', city:'bangalore', 'country': 'India'}};
var str = JSON.stringify(obj, undefined, 4); // indentation level = 2



Whereever you are standing, there is always a chance to go a step ahead. Your feedback will provide me the means to go ahead. I will be grateful to you for your kind comments/suggestions/feedbacks. If you would like to contact me for any reason, i.e, for feedback, query, suggestion, improvement(s) please drop a note here.

If you would like to contact me personally, please drop me an email to: I will try to respond you as soon as possible.