Day 2 Flashcards
The _____ and ______ were introduced in ES6, making them a modern JS syntax. They are a new way of declaring variables.
let and const
While the _____ variable is the old way of declaring variables.
var
We use _____ keyword to declare variables that can change values later.
let
When you change the value of a variable, its technical term is called _________ a value.
Reassigning or mutating
We also use let whenever we want to declare ______________. It is a common practice to declare variables with empty values (usually at the top of the file) and then reassign them later.
empty variables
On the other hand, we use the _______ keyword to declare variables that are NOT supposed to change at any point in the future. So the values declared with this cannot be changed.
const
You will get a _______________, if you attempt to change the value of a variable declared with const.
TypeError
In techical terms, variables declared with const are ___________ variable.
immutable
True of false: Now the fact that variables created with const are immutable, it also means that we CANNOT declare empty const variables.
True
True of false: You can declare empty variable with const.
False - variables declared with const are immutable.
Is this valid: const job;
No. You can’t declare an empty variable with const, you need to assign them with an initial value (initializer)
Basically, we need an ________ value (or __________) when using const declaration.
Initial or initializer
True of false: It is a best practice to always use const by default and let only if you are really sure that the variable needs to change at some point in the future.
True
True of false: It is a best practice to have as little variable mutation or variable changes as possible, because changing variables introduces a potential to create bugs.
True
Another way to declare variables, but should now be avoided.
var
Prior to ES6, _____ is used to create variables.
var
At first sight, it works pretty much the same as let.
var
True or false: It’s recommended to still use var in modern JavaScript.
False - use let or const instead
True or false: You can actually declare a variable without the use of let, const, or var but it’s a bad practice, and you’ll learn more later why.
True
This operators perform arithmetic on numbers (literals or variables).
Arithmetic operators
True or false: You can log multiple values in console.log(ageJonas, ageSarah)
True
True or false: You cannot perform arithmetic operations inside of console.log()
False - you can
What is exponentiation operator looked like?
**
True or false: We can use the plus operator to join or concatenate strings.
True