TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Dealing with JavaScript's Automatic Semicolon Insertion

3 pointsby niyazpkover 12 years ago

1 comment

elclanrsover 12 years ago
-"But to save yourself time and troubles, just place them all the time"- Or to save even more time, just put semicolons before raw expressions (not very common at all) and omit them everywhere else. ASI is a feature not a problem like many people make it look like. A good informative article nonetheless.<p><pre><code> ;(function(){}()) // Common IIFE 'use strict'; // need semicolon here // Not very common without an assignment ;'string'.method() ;[0,1,2,3].method() ;/regex/.method()</code></pre>