{"id":16,"date":"2007-09-18T12:05:07","date_gmt":"2007-09-18T18:05:07","guid":{"rendered":"http:\/\/www.philhassey.com\/blog\/2007\/09\/18\/language-hangups\/"},"modified":"2007-10-31T09:02:36","modified_gmt":"2007-10-31T15:02:36","slug":"language-hangups","status":"publish","type":"post","link":"https:\/\/www.philhassey.com\/blog\/2007\/09\/18\/language-hangups\/","title":{"rendered":"language hangups"},"content":{"rendered":"<p>I&#8217;ve spent a bit of time fooling with javascript this past weekend.  It really is okay, but I came across a few scoping gotcha.  Scoping defaults to global, so<\/p>\n<pre>function fnc1() { a = 5; } fnc1(); alert(\"a: \"+a);<\/pre>\n<p>Will show you that a is 5.  I&#8217;m more used to languages that default to a local scope.  To get variables into a local scope in javascript, this example should be written as:<\/p>\n<pre>b = null; function fnc2() { var b = 5; } fnc2(); alert(\"b: \"+b);<\/pre>\n<p>Will show you that b is null &#8211; as expected.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve spent a bit of time fooling with javascript this past weekend. It really is okay, but I came across a few scoping gotcha. Scoping defaults to global, so function fnc1() { a = 5; } fnc1(); alert(&#8220;a: &#8220;+a); Will show you that a is 5. I&#8217;m more used to languages that default to a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,8],"tags":[],"class_list":["post-16","post","type-post","status-publish","format-standard","hentry","category-javascript","category-languages"],"_links":{"self":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/16","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/comments?post=16"}],"version-history":[{"count":0,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/16\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/media?parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/categories?post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/tags?post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}