Course Content
Introduction to TypeScript
Introduction to TypeScript
Simple variable declaration
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/Java_OOP/TS_meme_3%404x.png)
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/Java_OOP/Definition_1.png)
Variables greatly simplify the lives of all developers. You can store text, numbers, or a boolean value (true
or false
) in a variable. Let's look at the syntax for creating a variable and displaying it in the console:
As you can see, the syntax for declaring a variable looks like this:
Also, note that when we use the let
keyword to declare a variable, both TypeScript and JavaScript automatically determine what type this variable should be. TypeScript allows you to specify the data type of a variable (that's why it's called TypeScript), which I will tell you about later in this course. For now, let's focus on simple variable declarations.
Note
Remember that we use
let
andconst
instead ofvar
. For now, the examples will still includevar
because it's the older way of declaring variables in TypeScript and JavaScript that has been around for a long time. Later on, we will explore the newer ways of declaring variables.
Arithmetic Operations in TypeScript
TypeScript, like any other programming language, supports simple and complex mathematical operations. Let's take a look at basic operations:
- Addition (
+
): Adds two numbers:
- Subtraction (
-
): Subtracts one number from another:
- Multiplication (
*
): Multiplies two numbers:
- Division (
/
): Divides one number by another:
- Modulus (
%
): Returns the remainder of the division:
- Exponentiation (
**
orMath.pow()
):** Raises a number to a power:
Phew, I hope, I've listed everything. This is a list of the most commonly used arithmetic operations in TypeScript. I'll tell you how to use these operations in the next chapter, where you'll learn how to use them correctly and what you can achieve with their help.
How to declare a variable in TypeScript?
Select a few correct answers
Everything was clear?
Course Content
Introduction to TypeScript
Introduction to TypeScript
Simple variable declaration
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/Java_OOP/TS_meme_3%404x.png)
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/Java_OOP/Definition_1.png)
Variables greatly simplify the lives of all developers. You can store text, numbers, or a boolean value (true
or false
) in a variable. Let's look at the syntax for creating a variable and displaying it in the console:
As you can see, the syntax for declaring a variable looks like this:
Also, note that when we use the let
keyword to declare a variable, both TypeScript and JavaScript automatically determine what type this variable should be. TypeScript allows you to specify the data type of a variable (that's why it's called TypeScript), which I will tell you about later in this course. For now, let's focus on simple variable declarations.
Note
Remember that we use
let
andconst
instead ofvar
. For now, the examples will still includevar
because it's the older way of declaring variables in TypeScript and JavaScript that has been around for a long time. Later on, we will explore the newer ways of declaring variables.
Arithmetic Operations in TypeScript
TypeScript, like any other programming language, supports simple and complex mathematical operations. Let's take a look at basic operations:
- Addition (
+
): Adds two numbers:
- Subtraction (
-
): Subtracts one number from another:
- Multiplication (
*
): Multiplies two numbers:
- Division (
/
): Divides one number by another:
- Modulus (
%
): Returns the remainder of the division:
- Exponentiation (
**
orMath.pow()
):** Raises a number to a power:
Phew, I hope, I've listed everything. This is a list of the most commonly used arithmetic operations in TypeScript. I'll tell you how to use these operations in the next chapter, where you'll learn how to use them correctly and what you can achieve with their help.
How to declare a variable in TypeScript?
Select a few correct answers
Everything was clear?