{"id":59,"date":"2015-09-23T00:03:30","date_gmt":"2015-09-23T00:03:30","guid":{"rendered":"http:\/\/dev.fruitbyte.com\/?p=59"},"modified":"2015-09-23T00:03:54","modified_gmt":"2015-09-23T00:03:54","slug":"javascripts-this-is-nuts","status":"publish","type":"post","link":"http:\/\/dev.fruitbyte.com\/?p=59","title":{"rendered":"Javascript&#8217;s this is nuts"},"content":{"rendered":"<p>It&#8217;s not going to be a rant as title might suggest you. I&#8217;ve been reading a book about Phonegap (now known as Apache Cordova), and came across a cool remark in the text:<\/p>\n<blockquote><p>Javascript&#8217;s this is a bit<br \/>\nnuts, so it&#8217;s always better to refer to a variable that we know<br \/>\nwill always refer to the object.<\/p><\/blockquote>\n<p>I smiled. This remark was referring to a simple code that had this assignment:<\/p>\n<p><code>self = this<\/code><\/p>\n<p>I&#8217;ve learned about JS &#8220;this&#8221; the hard way. Indeed, it&#8217;s not intuitive and goes against what developer learned from other languages. Anyway, I thought I know how it works well&#8230; until I read this quote. I went back online to refresh my knowledge, just to learn the damn thing again. \ud83d\ude42 Anyway, in case if you&#8217;re in the same boat, old friend MDN (Mozilla Developer Network) is your friend. That&#8217;s the best article about &#8220;this&#8221; scope, strict and non-strict mode (who came up with these names!?), syntax for event handlers etc.<\/p>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators\/this\" target=\"_blank\">Here&#8217;s the link<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s not going to be a rant as title might suggest you. I&#8217;ve been reading a book about Phonegap (now known as Apache Cordova), and came across a cool remark in the text: Javascript&#8217;s this is a bit nuts, so &hellip; <a href=\"http:\/\/dev.fruitbyte.com\/?p=59\"><em>Continue&nbsp;reading&nbsp;<span class=\"meta-nav\">&rarr;<\/span><\/em><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,41,22],"tags":[42,52,53,51],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-computer-languages","category-javascript","category-web","tag-javascript","tag-scope","tag-strict","tag-this"],"_links":{"self":[{"href":"http:\/\/dev.fruitbyte.com\/index.php?rest_route=\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/dev.fruitbyte.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dev.fruitbyte.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dev.fruitbyte.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/dev.fruitbyte.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=59"}],"version-history":[{"count":2,"href":"http:\/\/dev.fruitbyte.com\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":61,"href":"http:\/\/dev.fruitbyte.com\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions\/61"}],"wp:attachment":[{"href":"http:\/\/dev.fruitbyte.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dev.fruitbyte.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dev.fruitbyte.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}