{"id":69,"date":"2024-02-16T03:10:59","date_gmt":"2024-02-16T03:10:59","guid":{"rendered":"https:\/\/anuraggandhi.com\/?p=69"},"modified":"2024-03-03T19:36:56","modified_gmt":"2024-03-03T19:36:56","slug":"javascript-gotchas","status":"publish","type":"post","link":"http:\/\/ag.wp\/javascript-gotchas\/","title":{"rendered":"Javascript Gotchas"},"content":{"rendered":"\n

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.<\/p>\n\n\n\n

JSON to Pretty Print JSON string<\/h3>\n\n\n\n
<\/circle><\/circle><\/circle><\/g><\/svg><\/span><\/path><\/path><\/svg><\/span>
var<\/span> emp <\/span>=<\/span> <\/span>{<\/span> <\/span>name<\/span>:<\/span>'<\/span>John Doe<\/span>'<\/span>,<\/span> <\/span>'<\/span>email<\/span>'<\/span>:<\/span>'<\/span>foo@bar.com<\/span>'<\/span>,<\/span> <\/span>age<\/span>:<\/span> <\/span>40<\/span>,<\/span> <\/span>address<\/span>:{<\/span> <\/span>line1<\/span>:<\/span> <\/span>'<\/span>1st  street<\/span>'<\/span>,<\/span> <\/span>city<\/span>:<\/span>'<\/span>New York<\/span>'<\/span>,<\/span> <\/span>'<\/span>country<\/span>'<\/span>:<\/span> <\/span>'<\/span>India<\/span>'<\/span>}};<\/span><\/span>\nvar<\/span> str <\/span>=<\/span> JSON<\/span>.<\/span>stringify<\/span>(obj<\/span>,<\/span> <\/span>undefined,<\/span> <\/span>4<\/span>)<\/span>;<\/span> <\/span>\/\/ indentation level = 4<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"

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\u2026 Read More »<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/ag.wp\/wp-json\/wp\/v2\/posts\/69"}],"collection":[{"href":"http:\/\/ag.wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ag.wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ag.wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ag.wp\/wp-json\/wp\/v2\/comments?post=69"}],"version-history":[{"count":1,"href":"http:\/\/ag.wp\/wp-json\/wp\/v2\/posts\/69\/revisions"}],"predecessor-version":[{"id":124,"href":"http:\/\/ag.wp\/wp-json\/wp\/v2\/posts\/69\/revisions\/124"}],"wp:attachment":[{"href":"http:\/\/ag.wp\/wp-json\/wp\/v2\/media?parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ag.wp\/wp-json\/wp\/v2\/categories?post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ag.wp\/wp-json\/wp\/v2\/tags?post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}