Skip to content

Defensive programming benefit of the bang method ("!") is not correct. #44

Closed
@heavysixer

Description

First off this is a great document, and thanks for sharing it. I have read the entire file end-to-end as I work on my own personal style guide. However, I was looking at your module example and you assert that "!" protects you from concatenation errors. However, I don't think this is correct. Consider the following example:

// => SyntaxError: Unexpected token !
!function(){console.log("ham");}()!function(){console.log("cheese")}();

Maybe I am misunderstanding how you expected things to work.

I think you still need to prepend a semicolon to truly protect yourself from concatenation errors.

;!function(){console.log("ham");}()

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions