TypeScript programs are made up from a series of instructions called
statements. These instructions are read by the computer (the browser) from the
top to the bottom and from left to right.
In many TypeScript programs you will see that each statement ends with a
;). While not absolutely necessary, some teams will use this style.
At SDG we follow a style where the semicolons are not required. In fact we
recommend you use an automatic code formatter named
Prettier which will ensure proper style.
Each line of code represents a single idea. Even though our computers seem smart, computers are simple machines that really only understand 1 very simple command at a time. The advantage that computers have over people is that they run those simple commands really fast.
Most of what we do when we write code is one of two actions: storing data or manipulating data. Let's start with storing data.
When writing code we can leave comments to document the code. This helps remind the author, or other readers, to the purpose of the code.
Comments look like this:
// This is a single line comment/* This is a longer commentthat spans multiple lines*/
Comments behave like whitespace and are discarded during script execution.