{"id":322,"date":"2007-09-17T09:18:29","date_gmt":"2007-09-17T14:18:29","guid":{"rendered":"http:\/\/www.juixe.com\/techknow\/index.php\/2007\/09\/17\/twelve-elements-of-javascript-style\/"},"modified":"2012-07-14T10:06:23","modified_gmt":"2012-07-14T17:06:23","slug":"twelve-elements-of-javascript-style","status":"publish","type":"post","link":"http:\/\/juixe.com\/techknow\/index.php\/2007\/09\/17\/twelve-elements-of-javascript-style\/","title":{"rendered":"Twelve Elements of JavaScript Style"},"content":{"rendered":"<p>I&#8217;ve been reading a lot of articles and viewing many presentations on JavaScript.  One of the most prolific writer and presenter on the subject is Yahoo!&#8217;s <a href=\"http:\/\/www.crockford.com\/\">Douglas Crockford<\/a>.  I&#8217;ve recently rediscovered Crockford&#8217;s classic article on <a href=\"http:\/\/javascript.crockford.com\/style1.html\">The Elements of JavaScript Style<\/a> (part <a href=\"http:\/\/javascript.crockford.com\/style2.html\">2<\/a>).  Between these two articles Crockford lists 12 key elements of JavaScript style.<\/p>\n<ul>\n<li>Avoid archaic constructions.<\/li>\n<li>Always use blocks in structured statements.<\/li>\n<li>Avoid assignment expressions.<\/li>\n<li>Use object augmentation.<\/li>\n<li>Use common libraries.<\/li>\n<li>Watch out for type coercion when using ==.<\/li>\n<li>Use the ?: operator to select one of two values.<\/li>\n<li>Don&#8217;t use the ?: operator to select one of two actions.<\/li>\n<li>Use the || operator to specify a default value.<\/li>\n<li>Never use implicit global variables.<\/li>\n<li>global variables are evil.<\/li>\n<li>Use inner functions to avoid global variables.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been reading a lot of articles and viewing many presentations on JavaScript. One of the most prolific writer and presenter on the subject is Yahoo!&#8217;s Douglas Crockford. I&#8217;ve recently rediscovered Crockford&#8217;s classic article on The Elements of JavaScript Style (part 2). Between these two articles Crockford lists 12 key elements of JavaScript style. Avoid [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[16,19,3],"tags":[769,333,804,770,768],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p902K-5c","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/322"}],"collection":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/comments?post=322"}],"version-history":[{"count":1,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/322\/revisions"}],"predecessor-version":[{"id":1656,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/322\/revisions\/1656"}],"wp:attachment":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/media?parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/categories?post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/tags?post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}