Javascript Fundamentals Flashcards

1
Q

How do you declare a variable?

A

let name = value

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

What are the rules for naming variables?

A

can’t start with a number

can’t contain special characters except for $ and _

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

What are operators, operands, and operations?

A

Operators - the symbol in an operation
Operands - The numbers
Operations - tho sum as a whole

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

What is concatenation and what happens when you add numbers and strings together?

A

String concatonation is the joining of multiple strings into one string

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

What is the difference between == and ===?

A

Double equals (==) is a comparison operator, which transforms the operands having the same type before comparison.

So, when you compare string with a number, JavaScript converts any string to a number. An empty string is always converts to zero. A string with no numeric value is converts to NaN (Not a Number), which returns false.
What is === in JavaScript?

=== (Triple equals) is a strict equality comparison operator in JavaScript, which returns false for the values which are not of a similar type. This operator performs type casting for equality. If we compare 2 with “2” using ===, then it will return a false value.

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

What are operator precedence values?

A

BODMAS

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

What are the increment/decrement operators?

A

++

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

What is the difference between prefixing and post-fixing the increment/decrement operators?

A

the postfix form counter++ also increments counter but returns the old value (prior to increment

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

What is the “Unary +” Operator?

A

+=

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

What are the eight data types of javascript?

A

number - for numbers of any kind: integer or floating-point, integers are limited by ±253.
bigint - is for integer numbers of arbitrary length.
string - for strings. A string may have zero or more characters, there’s no separate single-character type.
boolean - for true/false.
null - for unknown values – a standalone type that has a single value null.
undefined - for unassigned values – a standalone type that has a single value undefined.
object - for more complex data structures.
symbol - for unique identifiers.

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

Which data type is NOT primitive?

A

object

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

What is the difference between single, double, and backtick quotes for strings?

A

There’s practically no difference between single and double quotes. Backtick quotes can be used to reference variables inside strings

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

Which type of quote lets you embed variables/expressions into a string?

A

backtick quote

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

How do you embed variables/expressions into a string?

A

${variable_name}

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

How do you escape characters in a string?

A

\

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

What is the difference between slice/substring/substr?

A

slice() extracts a part of a string and returns the extracted part in a new string.

substring() is similar to slice().
The difference is that substring() cannot accept negative indexes.

substr() is similar to slice().
The difference is that the second parameter specifies the length of the extracted part.

17
Q

What are methods?

A

a method is a bit of functionality that is built into the language or into specific data types

18
Q

What are the three logical operators and what do they stand for?

A

&& - AND
|| - OR
! - NOT

19
Q

What are the comparison operators?

A
== - equality
=== - strict equality
> - greater than
< - less than
>= - greater than or equal to
<= - less than or equal to
20
Q

What is nesting?

A

putting if/else statements inside other if/else statements

21
Q

What are truthy and falsy values?

A

In JavaScript, truthy are expressions which evaluates to boolean true value and falsy evaluates to boolean false value.

22
Q

What are the falsy values?

A
boolean false
empty string
undefined
null
NaN
0
23
Q

What is the syntax for an if/else conditional?

A
if (conditon) {
    code;
} else {
    code;
}
24
Q

What is the syntax for a switch statement?

A
switch (condition) {
    case evaluation:
        code;
        break;
    default:
        code;
25
Q

What is the syntax for a ternary operator?

A

(condition ? exprIfTrue : exprIfFalse);

26
Q

What is the relationship between null and undefined?

A

undefined means a variable has been declared but has not yet been assigned a value
null is an assignment value. It can be assigned to a variable as a representation of no value:

27
Q

What are conditionals?

A

statements that control whether or not a block of code will execute, if/else statements for examplelet