JavaScript Basics Module #16 Flashcards
What kind of error do you get if you try to reassign a new value to a const variable?
TypeError
Which 2 use cases can a const variable point to in which the content changes?
Object or Array
Which kind of variable should be used most often and why?
const because the less power our code has the better. This way, less bugs are introduced into our program.
What are the 4 primitive types?
Numbers, strings, booleans, symbols. There are also 2 special types, “null” and “undefined”.
What is an object type?
Any value that is not a primitive: (string, number, boolean or property).
What’s an expression?
A single unit of JS code that the JavaScript engine can evaluate.
Logical Expressions have 3 types, what are they?
&& (and) | | (or) !a (not)
What happens in JS when you divide a number by 0?
No error is returned, instead the value of Infinity or (-Infinity) is returned.
What is returned by this expression 1 % 0?
NaN (Not a Number)
What is returned by this expression -1 % 0?
NaN (Not a Number) Any time you use the remainder operator on a zero, it returns NaN.
How is the exponentiation operator expressed?
**
In JavaScript what is the order of operations for operators?
Multiplication, Division, Remainder, addition and subtraction. Anything inside of parenthesis are evaluated first.
What are the equality operators?
===Equality strict, !== Inequality strict (also == eqaulity and != inequality operator) *Strongly suggested to only use the strict operators ( less errors and less problems that are difficult to troubleshoot/diagnose)
How do you set up an if statement?
if (condition true){ // do something }
How do you set up an if /else statement?
if (condition true){ // do something } else { //do something else }