Number Flashcards

1
Q

Attributes

A
Primitive data type / immutable
Contains properties & methods
64 bit float
#safe
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Instantiation

A
// literal
1
// constructor; arg is converted into number, else NaN
Number(1)          // primitive
new Number(1)  // object
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Properties

A

Number.MAX_VALUE
=> highest number prior to becoming infinity
#safe
#static

Number.MIN_VALUE
=> lowest number prior to becoming 0
#safe
#static

.NaN
=> NaN
#safe
#static

Number.NEGATIVE_INFINITY
=> -Infinity
#safe
#static

Number.POSITIVE_INFINITY
=>  Infinity
#safe
#static
#examples:
  Number.POSITIVE_INFINITY === Infinity
  Number.NEGATIVE_INFINITY === Infinity * -1
  Number.POSITIVE_INFINITY === -Infinity * -1
  NaN === -Infinity * 0
  NaN === -Infinity / -Infinity
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Methods (?)

A

.toExponential —exponential form of number

.toFixed —number with fixed-point notation

.toPrecision —number in exponential or numeric form

.toString —number @ base of ?

.valueOf —convert object into primitive

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

Global methods related to numbers (4)

A

isFinite —determine if value could be a finite number

isNaN —determine if value is NaN

parseInt — convert value into integer from base

parseFloat —convert value into float

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

What is NaN

A

NaN — “Not a Number”, comes from Number.NaN, and is the result of an operation that failed to produce a number—such as Math.sqrt(-1)

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

What makes NaN totally unique?

A

NaN is the ONLY javascript data type that cannot use === (since it always evaluates to false). Example

NaN === NaN
=> false

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