Today I learned...
A division by 0 will also return Infinity.
Infinity is a number type.
- Hexadecimal - base 16
- Decimal - base 10
- Octal - base 8
- Binary - base 2
Numbers can also be defined as objects using the keyword new.
let o = new Number(100);
However, its best not to create Number objects since it may produce unexpected results, complicates the code, and slows down the execution speed.
An operator is unary if it has a single operand.
let x = -1;
When the unary plus operator, "+", is used on an operand that is not a number, it converts it into a number. An empty string and null become 0, true is 1, and false is 0. Space characters (\t, \n, etc.) are trimmed off when a string is converted to a number.
An operator is binary if it has two operands.
let x = 8 - 1;