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
Given that the variables are declared. Is this valid: console.log(firstName + ‘ ‘ + lastName);
Valid
Operator used to assign values to a variable
Assignment operator
This operator adds the value of the right operand to a variable and assigns the result to the variable.
addition assignment operator (+=)
This operator increments (adds one to) its operand and returns the value before or after the increment, depending on where the operator is placed.
increment operator (++)
We use ___________ operators to produce boolean values.
comparison (and of course logical)
True or false: The Console tab in developer tools has access to all variables in present in the browser tab.
True
JavaScript has a well-defined order of operator ___________. Basically, the order in which operators are executed.
precedence
True or false: Comparison operators has lower precedence than arithmetic operators. This means arithmetic operators executes first than comparison operators.
True
True or false: Most of the operators execute from left to right, but some execute from right to left like assignment operator.
True
True or false: You can declare two empty values: let x, y;
True
Give a type of operator that has right to left associativity
Assignment operator or exponential
What will be the value of x and y: x = y = 25 - 10 - 5;
10 and 10
Which has the highest order of precedence?
Grouping
What is the result: const ageAverage = 20 + 20 / 2;
30
What is the result: const ageAverage = (20 + 20) / 2;
20
It’s easier to building strings using _______________.
Template literal
Starting ES6, there’s a much easier way to concatenate strings with __________.
Template literal
We use ____________ to write template literals, and we can wrap variables inside of __________.
Backticks (``) and interpolation ${}
True or false: You can also write regular strings using template literals.
True
You can write multi line strings much easier with ______________.
template literals