var Declare a variable that can be changed later
let - Declare a variable that can be changed later
const - Declare a variable that can not be changed later
there are some other differences between
varandletto do with scope but we won't get into that for now.
&& and
|| or
! not
== Loose Equal (Equal value)
=== Strict Equal (Equal value && type)
!= Loose Not Equal (Not equal value)
!== Strict Not Equal (Not equal value || type)
> Greater Than
< Less Than
>= Greater Than || Equal To
<= Less Than || Equal To
+ Addition
+= Addition assignment
- Subtraction
-= Subtraction assignment
* Multiplication
*= Multiplication assignment
/ Division
/= Division assignment
% Modulus (Returns the remainder of a division)
%= Modulus assignment
** Exponentiation (multiply to the power of)
**= Exponentiation assignment
NumberAny numberBooleanRepresented as True or False (1 or 0)NullIntentional absence of a value (It exists, but it doesn't have a value)UndefinedAbsense of a value (it doesn't exist)BigIntUsed for storing numbers larger than 9,007,199,254,740,991StringGrouping of characters, aka text (letters, numbers, spaces, symbols, etc)SymbolUsed for anonymouse, unique values. (Useful in complex, security-driven applications)
- 0
- Empty strings like "" or ''
- null which represent when there is no value at all
- undefined which represent when a declared variable lacks a value
- NaN, or Not a Number
for (param1; param2; param3) {
// Code block to be executed
}For loops take in 3 parameters seperated with a semicolin ; instead of the usual comma ,
param1 - executes when the loop starts
param2 - the condition that must be met execute each loop
param3 - executes every time the loop is iterated
for (let i = 0; i < 10; i++) {
console.log(i)
}The above example will log i to the console 10 times as i increases with every iteration
while (condition) {
// Code block to be executed
}While loops take in a condition and will loop until that condition is no longer true
*Be extremely careful with
whileloops, as they are extremely easy to get stuck in an infinite loop, this can crash the page and/or computer running it.
let i = 0 // If we left out this line, it would never run!
while (i < 10) {
console.log(i)
i++ // If we forgot this, it would loop infinitely
}The above example will run 10 times, as you can see, we need to declare the value of i outside the loop. Otherwise it would never start the loop, because JavaScript doesn't know what i means
If we were to forget to increment i after each iteration, it would run forever. Since the condition would never be false, as i would never get higher than 0