JavaScript Fundamentals - Part One Flashcards

1
Q

What is a variable?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to declare a variable?

A

let myName;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to initialize a variable?

A

let myName = “Chris”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to redeclare a variable?

A

myName = “Bob”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the 7 primitive data types of JavaScript?

A

Number, String, Boolean, Undefined, Null, Symbol, BigInt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between let, const, and var?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the JavaScript Operators?

A

Assignment Operators, Arithmetic Operators, Comparison Operators, Logical Operators, Bitwise Operators, String Operators, other JavaScript Operators.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the Assignment Operators?

A

=, +=, -=, *=, /=, %=, **=.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the Arithmetic Operators?

A

+, -, *, /, %, ++, –, **.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the Comparison Operators?

A

==, !=, ===, !==, >, >=, <, <=.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the Logical Operators?

A

&&, ||, !.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the Bitwise Operators?

A

&, |, ^, ~, «,&raquo_space;,&raquo_space;>.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the String Operators?

A

Used to concatenate (join) two or more strings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are others JavaScript Operators?

A

(,), ?:, delete, typeof, void, in, instanceof

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is Operator Precedence in JavaScript?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are Template Literals?

A

Template literals are literals delimited with backtick (``) characters, allowing for multi-line strings, string interpolation with embedded expressions, and special constructs called tagged templates.

17
Q

What is the use of the if/else statement?

A

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.

18
Q

What is the difference between type coersion and type conversion in JavaScript?

A

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.

19
Q

What are truthy and falsy in JavaScript?

A

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.

20
Q

What is Strict Equality in JavaScript? How does it differ from the loose equality operator?

A

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.

21
Q

What are Logical Operators in JavaScript?

A

There are three logical operators in JavaScript: && (AND), || (OR), and !(NOT).

22
Q

Explain the OR(||) Operator.

A

It evaluates the operands from left to right and returns true whenever it encounters the first truthy value otherwise false.

23
Q

Explain the AND(&&) Operator.

A

Its operands will be true if and only if all the operands are true.

24
Q

Explain the NOT(!) Operator.

A

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.

25
Q

What is the Switch Statement in JavaScript?

A

The switch statement executes a block of code depending on different cases. The switch statement is a part of JavaScript’s Conditional Statements, which are used to perform different actions based on different conditions. Use switch to select one of many blocks of code to be executed.

26
Q

What is the difference between a Statement and an Expression in JavaScript?

A

Expression is a bit of a JavaScript code that produces a value. For example: 1 -> produces 1, “hello” -> produces “hello”. A JavaScript program, for instance, is a sequence of statements. Each statement is an instruction for the computer to do something. For example: let hi = 5, throw new Error(“Something exploded!”).

27
Q

What is a Ternary Operator?

A

A ternary operator can be used to replace an if…else statement in certain situations. A ternary operator evaluates a condition and executes a block of code based on the condition.