Primitive Types Module #17 Flashcards
How would you define a number using hexadecimal syntax?
Start with the 0x prefix.
How would you convert $10.00 so that the calculations are dependably exact?
Multiply by 100 ( 10 x 100 = 1000 ) Stripe uses this method and essentially dollar values are calculated in pennies. .01 === 1
How can you test for a “type” of a variable?
Use the "typeof" keyword. For example: const age = Number( 36 ) typeof age //number
How can an you create an object from a number type?
Use the "new" keyword in front of the number. For Example: const age = new Number ( 36 ) typeof age //object
What can you use to determine the original number value of an object?
METHOD
Use the value of method. Example:
age.valueOf ( )
Define EPSILON.
EPSILON is the smallest interval between two numbers.
Define MAX_SAFE_INTEGER.
MAX_SAFE_INTEGER is the maximum integer value JavaScript can represent.
Define MAX_VALUE.
MAX_VALUE is the maximum positive value that JavaScript can represent.
Define MIN_SAFE_INTEGER.
MIN_SAFE_INTEGER is the minimum integer value JavaScript can represent.
Define MIN_VALUE.
MIN_VALUE is the minimum positive value JavaScript can represent.
Define NaN
A special value representing “not a number”.
METHODS: How is the NaN method expressed in JavaScript?
Number.isNaN(value) returns true if value is not a number
METHODS: How is the finite number method expressed?
Number.isFinite(value): returns true if value is a finite number.
METHODS: How is the integer method expressed ?
METHOD
Number.isInteger(value): returns true if value is an integer.
METHODS: How is the “safe” integer method expressed ?
METHOD
Number.isSafeInteger(value): returns true if value is a safe integer.
METHODS: How is the floating point number method expressed?
Number.parseFloat(value): converts value to a floating point number and returns it.
METHODS: How is the value of a floating point number converted into an integer expressed as a method?
Number.parseInt(value): converts value to an integer and returns it. It can also convert strings with words, extracting the first number, but the string must start with a number.