Program Structure

Understand the basic structure of a program and the main components of a computer program.

We'll cover the following

We already defined a computer program as a list of commands telling a computer what to do. These orders are written as text files and makeup what’s called the “source code” of the program. The lines of text in a source code file are called lines of code. The source code may include empty lines: these will be ignored when the program executes.

Statements

Each instruction inside a program is called a statement. A statement in JavaScript usually ends with a semicolon (albeit it’s not strictly mandatory). Your program will be made up of a series of these statements.

You usually write only one statement per line.

Execution flow

When a program is executed, the statements in it are “read” one after another. It’s the combination of these individual results that produce the final result of the program.

Here’s an example of a JavaScript program including several statements, followed by the result of its execution.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy