You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/05-types/article.md
+8-33Lines changed: 8 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -213,18 +213,7 @@ O tipo `symbol` é usado para criar identificadores únicos para objetos. Nós o
213
213
214
214
O operador `typeof` retorna o tipo do argumento. É útil quando queremos processar valores de diferentes tipos de forma diferente ou apenas queremos fazer uma verificação rápida.
215
215
216
-
<<<<<<< HEAD
217
-
Suporta duas formas de sintaxe:
218
-
219
-
1. Como operador: `typeof x`.
220
-
2. Como uma função: `typeof(x)`.
221
-
222
-
Em outras palavras, trabalha com parênteses ou sem eles. O resultado é o mesmo.
223
-
224
216
A chamada para `typeof x` retorna uma string com o nome do tipo:
225
-
=======
226
-
A call to `typeof x` returns a string with the type name:
As três últimas linhas podem precisar de explicações adicionais:
256
245
257
-
<<<<<<< HEAD
258
246
1. `Math` é um objeto embutido que fornece operações matemáticas. Nós o vamos aprender no capítulo <info:number>. Aqui, ele serve apenas como um exemplo de um objeto.
259
-
2. O resultado de `typeofnull` é `"object"`. É um erro oficialmente reconhecido no comportamento de `typeof`e mantido para compatibilidade. Naturalmente, `null` não é um objeto. É um valor especial com um tipo separado próprio.
247
+
2. O resultado de `typeofnull` é `"object"`. É um erro oficialmente reconhecido no comportamento de `typeof`, vindo dos primeiros dias do JavaScript e mantido para compatibilidade. Naturalmente, `null` não é um objeto. É um valor especial com um tipo separado próprio. O comportamento de `typeof` é errado aqui.
260
248
3. O resultado de `typeof alert` é `"function"`, porque `alert` é uma função. Vamos estudar as funções nos próximos capítulos onde veremos também que não há nenhum tipo especial "função" em JavaScript. As funções pertencem ao tipo objecto. Mas o `typeof` as trata de forma diferente, retornando `"function"`. Isto, também vem dos primeiros dias do JavaScript. Tecnicamente, é incorreto, mas muito conveniente na prática.
261
249
262
-
## Resumo
263
-
=======
264
-
1. `Math` is a built-in object that provides mathematical operations. We will learn it in the chapter <info:number>. Here, it serves just as an example of an object.
265
-
2. The result of `typeofnull` is `"object"`. That's an officially recognized error in `typeof`, coming from very early days of JavaScript and kept for compatibility. Definitely, `null` is not an object. It is a special value with a separate type of its own. The behavior of `typeof` is wrong here.
266
-
3. The result of `typeof alert` is `"function"`, because `alert` is a function. We'll study functions in the next chapters where we'll also see that there's no special "function" type in JavaScript. Functions belong to the object type. But `typeof` treats them differently, returning `"function"`. That also comes from the early days of JavaScript. Technically, such behavior isn't correct, but can be convenient in practice.
267
-
268
-
```smart header="The `typeof(x)` syntax"
269
-
You may also come across another syntax:`typeof(x)`. It's the same as `typeof x`.
250
+
```smart header="A `sintaxe typeof(x)`"
251
+
Você pode também encontrar outra sintaxe:`typeof(x)`. è o mesmo que `typeof x`.
270
252
271
-
To put it clear: `typeof` is an operator, not a function. The parentheses here aren't a part of`typeof`. It's the kind of parentheses used for mathematical grouping.
253
+
Para deixar claro:`typeof`é um operador, não uma função. Os parêntesis aqui não fazem parte de`typeof`. São o tipo de parêntesis usados em matemática para agrupamento.
272
254
273
-
Usually, such parentheses contain a mathematical expression, such as `(2 + 2)`, but here they contain only one argument `(x)`. Syntactically, they allow to avoid a space between the `typeof` operator and its argument, and some people like it.
255
+
Geralmente, tais parêntesis contêm uma expressão matemática, como em`(2 + 2)`, mas aqui eles contêm apenas um argumento`(x)`. Sintáticamente, eles permitem evitar o espaço entre o operador`typeof`e o seu argumento, e algumas pessoas gostam disso.
274
256
275
-
Some people prefer `typeof(x)`, although the `typeof x` syntax is much more common.
257
+
Algumas pessoas preferem`typeof(x)`, embora a sintaxe `typeof x`seja muito mais comum.
276
258
```
277
259
278
-
## Summary
279
-
>>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831
260
+
## Resumo
280
261
281
262
Existem 8 tipos básicos em JavaScript.
282
263
@@ -291,14 +272,8 @@ Existem 8 tipos básicos em JavaScript.
291
272
292
273
O operador `typeof` nos permite ver que tipo está armazenado em uma variável.
293
274
294
-
<<<<<<< HEAD
295
-
- Duas formas: `typeof x` ou `typeof(x)`.
275
+
- Geralmente, usado como `typeof x`, mas `typeof(x)` também é possivel.
296
276
- Retorna uma string com o nome do tipo, como `"string"`.
297
277
- Para `null` retorna `"object"` -- isso é um erro na linguagem, não é realmente um objeto.
298
-
=======
299
-
- Usually used as `typeof x`, but `typeof(x)` is also possible.
300
-
- Returns a string with the name of the type, like `"string"`.
301
-
- For `null` returns `"object"` -- this is an error in the language, it's not actually an object.
302
-
>>>>>>>8d04d0d2db97276dbb2b451c30a7bd3e05d65831
303
278
304
279
Nos próximos capítulos, nos vamos concentrar nos valores primitivos e, uma vez familiarizados com eles, passaremos para os objetos.
0 commit comments