Numbers 16 Flashcards

1
Q

What are the two kinds of numeric values is JS?

A

Numbers: 64-bit floating point numbers and are also used for smaller integers
Bigints: represent numbers w an arbitrary precision

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

Whats the difference between ++/– as a prefix rather than a suffix?
foo++ vs. ++foo

A

prefix: it adds to foo then returns foo
suffix: it returns foo then adds to it

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

What are the three ways of converting values into numbers?

A

Number(x)
+x
parseFloat(x) (avoid this one)

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

What is the rule for finding NaN in arrays?

A

There is no rule. You must check to see how each array method handles NaN.

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

Why should you be careful with decimal fractions in JS?

A

Internally, js floating point numbers are represented with base 2, which means base 10 decimal fractions can’t always be represented precisely.

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

What are the four ways of converting Numbers to Integers in js?

A

Math.trunc chops off anything past deci
Math.floor always rounds down
Math.ceil always rounds up
Math.round rounds up or down

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