{"id":3566,"date":"2025-07-26T02:32:20","date_gmt":"2025-07-26T00:32:20","guid":{"rendered":"https:\/\/blog.tomayac.com\/2025\/07\/26\/what-a-difference-a-semicolon-makes\/"},"modified":"2025-07-26T02:32:20","modified_gmt":"2025-07-26T00:32:20","slug":"what-a-diffrence-a-semicolon-makes","status":"publish","type":"post","link":"https:\/\/tomayac.com\/wordpress\/2025\/07\/26\/what-a-diffrence-a-semicolon-makes\/","title":{"rendered":"What a diff&#8217;rence a semicolon makes"},"content":{"rendered":"\n\t\t\t<p>The other day, I was hit by a baffling <code>TypeError: console.log(...) is not a function<\/code>. Like, WTF \ud83e\udd14? Turns out, I was sloppily adding a quick <code>console.log('here')<\/code> statement for debugging purposes (as one does \ud83d\ude48), which happened to be right before an <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/IIFE\">IIFE<\/a>. I didn't put a <code>;<\/code>, as it was a throwaway statement I'd remove after finding the bug, but turns out that's the issue. StackOverflow contributor <a href=\"https:\/\/stackoverflow.com\/users\/4642212\/sebastian-simon\">Sebastian Simon<\/a> had the <a href=\"https:\/\/stackoverflow.com\/a\/31013390\">explanation<\/a>:<\/p>\n<blockquote>\n<p>It's trying to pass <code>function(){}<\/code> as an argument to the return value of <code>console.log()<\/code> which itself is not a function but actually undefined (check <code>typeof console.log();<\/code>). This is because JavaScript interprets this as <code>console.log()(function(){})<\/code>. <code>console.log<\/code> however is a function.<\/p>\n<\/blockquote>\n<p>Minimal repro:<\/p>\n<pre class=\"language-js\"><code class=\"language-js\">console<span class=\"token punctuation\">.<\/span><span class=\"token function\">log<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>\n<span class=\"token punctuation\">(<\/span><span class=\"token keyword\">function<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/code><\/pre>\n<p><a href=\"https:\/\/fedi.jaenis.ch\/@andre\">Andre<\/a> on Mastodon <a href=\"https:\/\/fedi.jaenis.ch\/@andre\/statuses\/01K10C5PY7JBYVXYG8T6J4SP4B\">reminded me<\/a> of <a href=\"https:\/\/front-end.social\/@chriscoyier\">Chris Coyier<\/a>'s excellent <a href=\"https:\/\/css-tricks.com\/web-development-merit-badges\/\">Web Development Merit Badges<\/a>, so I'm now proudly wearing mine: <em>&quot;Debugged something for over one hour where the fix was literally one character&quot;<\/em>:<\/p>\n<p><img src=\"https:\/\/blog.tomayac.com\/images\/merit-badge-onechar.svg\" alt=\"Debugged something for over one hour where the fix was literally one character\" \/><\/p>\n\n\t\t\t<p>\n\t\t\t\t<img alt=\"Thomas Steiner\" width=\"32\" height=\"32\" src=\"https:\/\/blog.tomayac.com\/feed.php?dl=https%3A%2F%2Fblog.tomayac.com%2F2025%2F07%2F26%2Fwhat-a-difference-a-semicolon-makes%2F&dp=%2F2025%2F07%2F26%2Fwhat-a-difference-a-semicolon-makes%2F&dt=What%20a%20diff'rence%20a%20semicolon%20makes\" alt=\"\">\n\t\t\t\t<br\/>This post appeared first on <a href=\"https:\/\/blog.tomayac.com\/2025\/07\/26\/what-a-difference-a-semicolon-makes\/\">https:\/\/blog.tomayac.com\/2025\/07\/26\/what-a-difference-a-semicolon-makes\/<\/a>.\n\t\t\t<\/p>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\t\t\tThe other day, I was hit by a baffling TypeError: console.log(&#8230;) is not a function. Like, WTF \ud83e\udd14? Turns out, I was sloppily adding a quick console.log(&#8216;here&#8217;) statement for debugging purposes (as one does \ud83d\ude48), which happened to be right before an I&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"intlwemo_wallet_address":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-3566","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/posts\/3566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/comments?post=3566"}],"version-history":[{"count":1,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/posts\/3566\/revisions"}],"predecessor-version":[{"id":3569,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/posts\/3566\/revisions\/3569"}],"wp:attachment":[{"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}