Comment
A comment is used to tell the computer that some text is a note for the developer and the code should not be executed.
Primitives
Boolean
A boolean can be
true
or false
.Number
A number can be any number.
String
A string is a collection of characters.
Array
An array is a special data type that can store multiple values of different data types.
Object
An object is a bunch of primitive values put together to make a new data type.
Function
A function allows the programmer to abstract some code and run it somewhere else.
primitives
Variables
In typescript, you can declare a new variable using
const
or let.
const vs let
Operators
Below are some of the most commonly used built-in operators.
operators
Functions
A function consists of two main parts, the function parameters, and the function body.
function parts
After the programmer writes the code they want in the function body. They can specify what should be returned from the function using the return keyword.
Return statement
function parameters
Call a function
To call a function you can use the function name followed by
() .
calling a function
Get the results of a function
get function result
String Interpolation
Because engineers work with strings of characters a lot, typescript makes it easy to compose them together with string interpolation.
string interpolation
Types
- number (numeric value)
- string (a collection of characters)
- array (many values)
- boolean (true of false)
- any (any type)
In typescript, many types will be inferred by the system. Meaning you don't have to explicitly write them out. You can create your own types using the interface keyword.
custom type