-
Notifications
You must be signed in to change notification settings - Fork 0
/
erros.js
19 lines (11 loc) · 1.1 KB
/
erros.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*Cada linguagem de programação tem sua própria forma de lidar com erros.
O JavaScript começa dividindo cada tipo de erro possível em algumas categorias:
RangeError: Quando o código recebe um dado do tipo certo, porém não dentro do formato aceitável.
Por exemplo, um processamento que só pode ser feito com números inteiros maiores ou iguais a zero, mas recebe -1.
ReferenceError: Normalmente ocorre quando o código tenta acessar algo que não existe, como uma variável que não foi definida;
muitas vezes é causado por erros de digitação ou confusão nos nomes utilizados, mas também pode indicar um erro no programa.
SyntaxError: Na maior parte dos casos ocorre quando há erros no programa e o JavaScript não consegue executá-lo.
Os erros podem ser métodos ou propriedades escritos ou utilizados de forma incorreta, por exemplo,
operadores ou sinais gráficos com elementos a menos, como esquecer de fechar chaves ou colchetes.
TypeError: Indica que o código esperava receber um dado de um determinado tipo, tal qual uma string de texto,
mas recebeu outro, como um número, booleano ou null.