Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
48 lines (36 loc) · 1.26 KB

File metadata and controls

48 lines (36 loc) · 1.26 KB
Copy raw file
Download raw file
Outline
Edit and raw actions

Sequencing

By calling one function after another, in sequence, you can have the program do different things in sequence.

doSomething();
doAnotherThing();

The semicolon

In JavaScript, the semicolon (;) is used to terminate (or end) a statement. However, in most cases, the semicolon is optional and can be omitted. So both code sequences below are legal:

doSomething()
doAnotherThing()
doSomething();
doAnotherThing();

The empty statement

In JavaScript, there is the concept of an empty statement, which is whitespace followed by a semicolon in the context where a statement is expected. So, the following code is an infinite loop followed by a call to doSomething that will never execute:

while(true) ;
doSomething(); // THIS LINE WILL NEVER EXECUTE!

~hint

To avoid this problem, we don't allow a program to contain an empty statement, such as shown above. If you really want an empty statement, you need to use curly braces to delimit an empty statement block:

while(true) { } 
doSomething(); // THIS LINE WILL NEVER EXECUTE!

~

Read more about semicolons in JavaScript.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.