Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to express at the end of a javascript statement

Shulou Source: shulou.com Published: 2022-05-31 11:56:27 09月15日 Update

This article mainly explains "how to express at the end of javascript sentence". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to express at the end of the javascript sentence.

Javascript can be expressed in semicolons in the end, but the addition or absence of semicolons depends entirely on personal habits, but for the sake of code stability, semicolon sentences are recommended.

This article operating environment: windows7 system, javascript1.8.5 version, Dell G3 computer.

What did javascript say in the end?

The end of a JavaScript statement can be indicated by a semicolon;.

Adding semicolons or not depends entirely on personal habits, but for the sake of code stability (parsing errors), it is recommended to use semicolon sentences.

JavaScript automatic semicolon rule:

1. When there is a newline character (including a multiline comment with a newline character) and the next token does not match the previous syntax, the semicolon is automatically filled.

two。 When there is}, if the semicolon is missing, the semicolon will be filled.

3. When the program source code ends, if the semicolon is missing, the semicolon will be filled.

Conclusion:

1. Line breaks can completely replace semicolons in return, break, continue, post-increment, and post-decrement statements.

For statements beginning with several keywords of 2.var if do while for continue break return with switch throw try debugger, as well as empty statements, it does not matter whether the previous line is added with a semicolon or not.

3. Where expression statements and function expression statements, not followed by a semicolon is very dangerous, the situation is extremely complex.

4. Sentences that begin with (and] are extremely dangerous without a semicolon in front of them.

At this point, I believe you have a deeper understanding of "how to express at the end of the javascript sentence". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Semicolon statement end newline danger personal code content depending on suggestion beginning expression or learning complex practical deeper one line not much useful Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info Xiaomi MariaDB vpn