JavaScript Fundamentals - Part One Flashcards
What is a variable?
A variable is a container for a value, like a number we might use in a sum, or a string that we might use as part of a sequence.
How to declare a variable?
let myName;
How to initialize a variable?
let myName = “Chris”;
How to redeclare a variable?
myName = “Bob”;
What are the 7 primitive data types of JavaScript?
Number, String, Boolean, Undefined, Null, Symbol, BigInt
What is the difference between let, const, and var?
We use var if we want function-scoped variables that can be hoisted. let if we want block-scoped variables that can be reassigned. And const if we want block-scoped variables that are constant and cannot be reassigned.
What are the JavaScript Operators?
Assignment Operators, Arithmetic Operators, Comparison Operators, Logical Operators, Bitwise Operators, String Operators, other JavaScript Operators.
What are the Assignment Operators?
=, +=, -=, *=, /=, %=, **=.
What are the Arithmetic Operators?
+, -, *, /, %, ++, –, **.
What are the Comparison Operators?
==, !=, ===, !==, >, >=, <, <=.
What are the Logical Operators?
&&, ||, !.
What are the Bitwise Operators?
&, |, ^, ~, «,»_space;,»_space;>.
What are the String Operators?
Used to concatenate (join) two or more strings.
What are others JavaScript Operators?
(,), ?:, delete, typeof, void, in, instanceof
What is Operator Precedence in JavaScript?
Operator precedence in JavaScript determines the priority of operators in an operation. It determines which operators have higher precedence than others, and thus tells us the order to perform a given mathematical expression. Operators with higher precedence will become the operands of operators with lower precedence.
What are Template Literals?
Template literals are literals delimited with backtick (``) characters, allowing for multi-line strings, string interpolation with embedded expressions, and special constructs called tagged templates.
What is the use of the if/else statement?
The if…else statement executes a statement if a specified condition is truthy. If the condition is falsy, another statement in the optional else clause will be executed.
What is the difference between type coersion and type conversion in JavaScript?
Type coercion happens implicitly during operations or comparisons, where JavaScript automatically converts values to make them compatible. Type conversion, on the other hand, involves explicit conversion of values using functions or operators provided by JavaScript.
What are truthy and falsy in JavaScript?
When non-boolean values are used in a boolean context, such as the condition of an if statement, they will be coerced into either true or false. Values that are coerced into true are called truthy and values that are coerced into false are called falsy.
What is Strict Equality in JavaScript? How does it differ from the loose equality operator?
The strict equality (===) operator checks whether its two operands are equal, returning a Boolean result. Unlike the equality operator, the strict equality operator always considers operands of different types to be different.
What are Logical Operators in JavaScript?
There are three logical operators in JavaScript: && (AND), || (OR), and !(NOT).
Explain the OR(||) Operator.
It evaluates the operands from left to right and returns true whenever it encounters the first truthy value otherwise false.
Explain the AND(&&) Operator.
Its operands will be true if and only if all the operands are true.
Explain the NOT(!) Operator.
The logical NOT operator flips the value of a boolean. If the value is true, the NOT operator returns false. If the value is false, the NOT operator returns true.