Search code examples
javascriptsyntaxautomatic-semicolon-insertion

Is there a special character to prevent ASI


When writing Javascript without semicolons, \n becomes the idiomatic statement terminator, but sometimes it is actually not, which I would like to express in my code. So is there a special character that explicitly prevents Automatic Semicolon Insertion, to alleviate this uncertainty?

Please note that I am actually in favor of using semicolons where possible, but some of the people I work with want to omit them.


Solution

  • Yes, it exists by using the grouping operator (). No ASI happens inside of the parentheses.

    return (
        // expression
    );