Why so many semicolons in JavaScript?

前端 未结 10 1772
夕颜
夕颜 2021-02-13 03:22

I tend to be a prolific user of semicolons in my JavaScript:

var x = 1;
var y = 2;
if (x==y){do something};

I recently noticed that I was looki

10条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-13 03:57

    Semicolons mark the end of statements in JS, but I do not put semicolons after a close-brace, only after a statement within a brace and ALWAYS on a return statement.

    In your example I dont find it necessary.

提交回复
热议问题