-1
I am recently entering the angular world, and came across some tutorials where not even imports and also the codes are without completion followed by ;
The use really becomes necessary?
And what’s the difference between using and not using?
-1
I am recently entering the angular world, and came across some tutorials where not even imports and also the codes are without completion followed by ;
The use really becomes necessary?
And what’s the difference between using and not using?
6
In theory, the mandatory semicolon exists in a single scenario, which is when the next line starts with one of the following symbols:
[
(
For example:
var x = { xx : "hello", yy : "world"}
(function () {
console.log("Hello World");
})();
Following the rule, the second line begins with a (
, then, it is mandatory the use of ;
at the end of the first / beginning of the second, thus:
var x = { xx : "hello", yy : "world"};
(function () {
console.log("Hello World");
})();
The reason for the point and comma existence in this scenario is somewhat complex, and well addressed in this article.
Therefore, it is possible, most of the time, to simply ignore the semicolon at the end of the sentences.
But when we talk about coding standarts, the recommended is to use the ;
where necessary.
I particularly adopt the pattern of always putting the ;
, when applicable. I believe it makes the code more readable and standardized.
Browser other questions tagged javascript angular typescript
You are not signed in. Login or sign up in order to post.
The question is about Javascript or Typescript?
– bfavaretto
At first it would be about the two, because they have characteristics of both languages, since I’m using ts, but the same is based on js
– Eduardo Gonçalves