GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Docs
  • JavaScript
  • Sequencing

This view

  • Original page
  • New address

GeezerVison is showing maker.makecode.com — Sequencing

Skip to main content
About FAQ Projects GitHub
Reference
music pins control serial
Blocks
On Start
Loops
repeat for while for of
Logic
if Boolean
Variables
assign change var var
Math JavaScript blocks Custom blocks
Python
Calling Sequencing Variables Operators Statements Functions Classes
JavaScript
Calling Sequencing Variables Operators Statements Functions Types Classes Interfaces Generics
Types
Number String Boolean Array Function
Miscellaneous
About Support Translate Sharing projects Offline support Save Reset Beta version Home page content
Developers
Command Line Interface Visual Studio Code support Blocks Embed

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!

No 'empty' statements

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.

Edit this page on GitHub
Edit template of this page on GitHub
Edit template of this page on GitHub

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.