Exemplo JavaScript

Número do JavaScript

Os números podem ser escritos com ou sem ponto decimal
Pode-se escrever números muito grandes ou muito pequenos usando a notação de exponencial
Os números são arredondados para 15 dígitos
A aritmética de ponto flutuante não é sempre 100% precisa
Mas pode ser resolvido multiplicando e dividindo por 10
Somar dois números produzirá um novo número
Somar duas strings de número produzirá uma string de concatenação
Somar um número e uma string de número também produzirá uma string de concatenação
Somar uma string de número e um número também produzirá uma string de concatenação
Erro comum ao somar strings e números 1
Common error 2 when adding strings and numbers
In division operations, JavaScript will try to convert strings to numbers
In multiplication operations, JavaScript will try to convert strings to numbers
In subtraction operations, JavaScript will try to convert strings to numbers
In addition operations, JavaScript will not convert strings to numbers
The number divided by a string is no longer a number
Dividing a number by a numeric string results in a number
The global JavaScript function isNaN() determines whether a value is a number
Using NaN in mathematical operations will always return NaN
Using NaN in mathematical string operations will concatenate NaN
The type of NaN is number (no, typeof NaN returns number)
If a number outside the maximum possible number is calculated, it returns infinity (Infinity)
Division by zero generates Infinity
Infinity is also a number (typeof Infinity returns number)
Constants prefixed with 0x are interpreted as hexadecimal
The toString() method can output numbers in hexadecimal, octal, or binary
Numbers can be objects
Numbers and objects cannot be safely compared
Objects and objects cannot be safely compared

Example Explanation: Numbers