{"id":1088,"date":"2019-05-23T00:16:01","date_gmt":"2019-05-22T14:16:01","guid":{"rendered":"http:\/\/www.moneystock.net\/wp_e\/?p=1088"},"modified":"2019-05-23T00:17:06","modified_gmt":"2019-05-22T14:17:06","slug":"javascript-best-practice-summary-jonathan-mills-from-pluralsight","status":"publish","type":"post","link":"https:\/\/moneystock.net\/wp_e\/2019\/05\/23\/javascript-best-practice-summary-jonathan-mills-from-pluralsight\/","title":{"rendered":"JavaScript best practice summary &#8211; Jonathan Mills from Pluralsight"},"content":{"rendered":"<p>Syntax &#8211; consistency is the king.<\/p>\n<ul>\n<li>Use semicolons.<\/li>\n<li>Use Linting. e.g. ESLint or JSHint<\/li>\n<li>Curly braces should start in the same line of command, which is different from C#, etc.<\/li>\n<li>Equality. Use === whenever possible.<\/li>\n<li>Write variable, function, caller in order.<\/li>\n<\/ul>\n<p>Behaviors &#8211; use strict mode.<\/p>\n<ul>\n<li>Use var if it&#8217;s not for a global variable<\/li>\n<li>Use &#8216;use strict&#8217;;\u00a0 This will remove weird JS behavior and throw an error rather than ignore silently.<\/li>\n<li>Use &#8216;var _this = this&#8217; pattern at the beginning of the object when creating a function object so as not to lose this scope inside the object.<\/li>\n<\/ul>\n<p>Async Patterns<\/p>\n<ul>\n<li>Callbacks\n<ul>\n<li>Use the named function.<\/li>\n<li>Return callback function like &#8216;done&#8217;.<\/li>\n<\/ul>\n<\/li>\n<li>\u00a0Promises\n<ul>\n<li>Use promise from promisejs, which can lead to monads.<\/li>\n<\/ul>\n<\/li>\n<li>ES6 and Babel\n<ul>\n<li>Use ES6 rather than ES5<\/li>\n<li>To use ES6 set up the environment using Babel which transpile ES5 JS to ES6 JS.<\/li>\n<\/ul>\n<\/li>\n<li>Async Await\n<ul>\n<li>New stuff<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Syntax &#8211; consistency is the king. Use semicolons. Use Linting. e.g. ESLint or JSHint Curly braces should start in the same line of command, which is different from C#, etc. Equality. Use === whenever possible. Write variable, function, caller in order. Behaviors &#8211; use strict mode. Use var if it&#8217;s not for a global variable&hellip; <a class=\"more-link\" href=\"https:\/\/moneystock.net\/wp_e\/2019\/05\/23\/javascript-best-practice-summary-jonathan-mills-from-pluralsight\/\">Continue reading <span class=\"screen-reader-text\">JavaScript best practice summary &#8211; Jonathan Mills from Pluralsight<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[552],"tags":[554],"class_list":["post-1088","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-javascript","entry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/posts\/1088","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/comments?post=1088"}],"version-history":[{"count":1,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/posts\/1088\/revisions"}],"predecessor-version":[{"id":1090,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/posts\/1088\/revisions\/1090"}],"wp:attachment":[{"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/media?parent=1088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/categories?post=1088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/tags?post=1088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}