variables & datatypes Flashcards

1
Q

Shorten the below

let user = ‘John’;
let age = 25;
let message = ‘Hello’;

A

let user = ‘John’, age = 25, message = ‘Hello’;

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

let hello = ‘Hello world!’;
let message;
message = hello;

alert(hello); // returns?
alert(message); // returns?

A

Hello world!
Hello world!

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

varibles cannot start with a _____ or have a _____

A

digit
hyphon

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

reserved variable words

A

let, class, return, function

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

Besides regular numbers, there are so-called “special numeric values” which also belong to this data type; name the 3

A

Infinity, -Infinity and NaN.

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

alert( 1 / 0 ); // returns

A

infinity

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

alert( “not a number” / 2 )

returns?

A

infinity

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

alert( NaN + 1 ); // returns

A

NAN

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

alert( 3 * NaN ); // returns

A

NAN

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

alert( “not a number” / 2 - 1 )
// returns

A

NAN

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

So, if there’s a NaN somewhere in a mathematical expression, it propagates to the whole result (there’s only one exception to that: )

A

NaN ** 0 is 1

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

let name = “John”;

// embed a variable
alert( Hello, \_\_\_\_\_\_ ! ); // Hello, John!

A

${name}

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

The expression inside ${…} is evaluated and the result becomes a part of the string but can only be done with ______.

A

backticks
``

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

______ is just a special value which represents “nothing”, “empty” or “value unknown”.

A

NULL

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

The meaning of ________ is “value is not assigned”.

A

undefined

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

let age;
alert(age); // returns?

A

shows “undefined”

17
Q

typeof undefined //
returns?

A

“undefined”

18
Q

typeof 10n // returns?

A

“bigint”

19
Q

typeof null // returns?

A

“object”