{"id":23,"date":"2016-02-23T02:18:23","date_gmt":"2016-02-23T02:18:23","guid":{"rendered":"http:\/\/www.onux.com\/jspp\/blog\/?p=23"},"modified":"2016-06-06T03:32:17","modified_gmt":"2016-06-06T03:32:17","slug":"design-notes-void-and-undefined","status":"publish","type":"post","link":"https:\/\/www.onux.com\/jspp\/blog\/design-notes-void-and-undefined\/","title":{"rendered":"Design Notes: void and undefined"},"content":{"rendered":"<p>JS++ replaces the &#8220;void&#8221; keyword as a type annotation rather than being like JavaScript which dictates that &#8220;void&#8221; is a keyword used to evaluate an expression and always returns undefined. This doesn&#8217;t serve much practical purpose.\u00a0You can accomplish the same effect in many other ways:<\/p>\n<pre class=\"brush: js\">\r\n\/\/ Original\r\nvar a = void foo();\r\n\r\n\/\/ Equivalent to:\r\nvar b = (foo(), undefined);\r\nvar c = (function(){ foo(); })();\r\n\/\/ ... etc\r\n<\/pre>\n<p>Furthermore, &#8220;void&#8221; is very rarely used in real-world JavaScript. This is why I always say it takes an experienced JavaScript programmer to design a JavaScript superset. It takes someone with deep experience in JavaScript to identify this in order to make such a breaking change with confidence. If you&#8217;re introducing a breaking change, make sure it&#8217;s just breaking the 1% and not the 99%.<\/p>\n<p>The enlightened few will use <code>void 0<\/code> in place of <code>undefined<\/code> because the ECMAScript 3 standard defines <code>undefined<\/code> as a global property that <em>can be defined<\/em>!<\/p>\n<p>JS++, on the other hand, makes <code>undefined<\/code> a keyword. <code>void<\/code> is then used as a type which represents both <code>null<\/code> and <code>undefined<\/code>.<\/p>\n<p>Finally, there have been informal plans for a JS to JS++ translator. This will handle those few instances where <code>void 0<\/code> is used to mean <code>undefined<\/code> and such. These cases are easy to parse and identify, and it makes introducing such a breaking change fathomable.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JS++ replaces the &#8220;void&#8221; keyword as a type annotation rather than being like JavaScript which dictates that &#8220;void&#8221; is a keyword used to evaluate an expression and always returns undefined. This doesn&#8217;t serve much practical purpose.\u00a0You can accomplish the same effect in many other ways: \/\/ Original var a = void foo(); \/\/ Equivalent to: &hellip; <a href=\"https:\/\/www.onux.com\/jspp\/blog\/design-notes-void-and-undefined\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Design Notes: void and undefined&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/posts\/23"}],"collection":[{"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":4,"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":52,"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions\/52"}],"wp:attachment":[{"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}