Javascript (Hack Reactor) Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What does ‘NaN’ mean?

A

Not A Number
i.e. “I think you meant to have a number here, but I cannot produce a number with what you gave me, so have NaN instead :)

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

Data types (8)

A

Scalar:
(1) Number
(2) BigInt
(3) String
(4) Boolean (logical type)
(5) null
(6) undefined

(7) Objects and (8) Symbols

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

How to format a string to be replaced with variables?

A

Use backticks
` random text ${variable} here `

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

What is the difference in formatting a string with variable replacements in JS and formatting a string in Python?

A

In Python we format strings using f strings e.g.
f’random text {variable} here’

In JS we use backticks and preface variable replacement with $
` random text ${variable} here `

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

Method to find the length of a string?

A

string.length

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

How to format if else statement?

A

if (cond) {
// code to execute
} else {
// code to execute
}

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

How to format function?

A

function checkAge(age) {
# code
}

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

How to specify a line as a comment?

A

Preface with // (forward slashes)

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

How to delete the key and value of an object?

A

delete obj[key]

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

How to access the value of an object?

A

bracket notation
obj[key]

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

Does NULL == undefined?

A

No, these are different data types

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

In what two scenarios would ‘undefined’ be returned?

A
  • when we do not specify what should be returned in our function
  • variable declared at but not assigned a value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Booleans in JS vs booleans in Python

A

lowercase true or false

Python, the booleans are capitalised True or False

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

Which equality operator should we use to err on the side of caution?

A

triple equals

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

How to express these operators:
and
or

A

symbols
&&
||

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