Types and Grammar Flashcards

1
Q

What is a type?

A

A type is an intrinsic build in set of characteristics that uniquely distinguishes the behavior

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

Javascripts built in types (7)

A
null
undefined
boolean
number
string
object
symbol
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Except for objects, all JS types are called:

A

Primitives

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

Function is what type?

A

object. Specifically a “callable object”

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

function.length returns

A

the number of formal parameters is it declared with

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

Array is what type?

A

A subtype of object

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

typeof [“d”,”a”]

A

object

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

var a;

typeof a

A

undefined

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

undefined vs undeclared

A

Undefined has been defined in accessible scope but not defined. Undeclared hasn’t been declared.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
var a = []
a["13"] = "hello";
What will happen?
A

a will be populated with undefined until a[13] which is hello

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

mutability of strings

A

immutable

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

mutability of arrays

A

mutable

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

with a decimal value of eg 0.42, is the 0 optional?

A

yes

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

With a decimal value of 42.30, is the 0 optional?

A

yes

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

Why is 0.1 + 0.2 == 0.3 false?

A

Binary floating point numbers are not exact. It’s actually like .300000000004. This is like a number epsilon.

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

Whats the best way to compare float calculations?

A

Use a tiny rounding error. See that a - b < Number.EPSILON

17
Q

Can you create

var undefined in unstrict more?

A

yes

18
Q

NaN is a type of

A
Number. 
eg var a = 1+"foo"
typeof a === "number" >> true
19
Q

How to check if a value is NaN and why?

A

isNaN(a)

We have to do this because NaN is a type of number

20
Q

downfalls with isNaN

A

Literally checks if it is NaN. Strings return true for example instead of whether it is a NaN subtype

21
Q

What can you do to check if it is type NaN?

A
var a = 3/"hello"
Number.isNaN(a)
22
Q

1/0 is

A

infinity