Javascript Flashcards

1
Q

What are 7 built-in types in JavaScript (ES6)?

A

null, undefined, boolean, number, string, object, and symbol.

All are primitives except for object

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

Null vs. Undefined?

A

Undefined is the absence of a definition. It is used as the default value for uninitialized variables, function arguments that were not provided and missing properties of objects.
- Functions return undefined when nothing has been explicitly returned.

Null is the absence of a value. It is an assignment value that can be assigned to a variable as a representation of ‘no-value’.

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

Implicit Coercion. Boolean coercion. What is falsy and what is truthy?

A

Falsy values: “”, 0, null, undefined, NaN, false.

Truthy: everything else. Empty arrays, objects, and functions are coerced to true.

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

String & Number coercion. What can you tell me?

A

The + operator works for both strings and numbers.
The *, /, and - operators are exclusive for numeric operations. When strings use these, they will be coerced to a number.

If a + is used with strings and numbers, they will be coerced into a string.

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

== vs. ===

A
== checks for equality with coercion. 
=== checks for equality without coercion. strict equality.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly