From 83d20033e47a3fa19fbcbf8b423aa7226a65b18f Mon Sep 17 00:00:00 2001 From: Tofpu <47629321+Tofpu@users.noreply.github.com> Date: Tue, 16 Nov 2021 09:37:00 +0200 Subject: [PATCH 01/12] added showStep method to our chain in the task --- 1-js/04-object-basics/04-object-methods/8-chain-calls/task.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/1-js/04-object-basics/04-object-methods/8-chain-calls/task.md b/1-js/04-object-basics/04-object-methods/8-chain-calls/task.md index eca9f4e92..a2a19c620 100644 --- a/1-js/04-object-basics/04-object-methods/8-chain-calls/task.md +++ b/1-js/04-object-basics/04-object-methods/8-chain-calls/task.md @@ -28,12 +28,14 @@ ladder.up(); ladder.up(); ladder.down(); ladder.showStep(); // 1 +ladder.down(); +ladder.showStep(); // 0 ``` Modify the code of `up`, `down` and `showStep` to make the calls chainable, like this: ```js -ladder.up().up().down().showStep(); // 1 +ladder.up().up().down().showStep().down().showStep(); // shows 1 then 0 ``` Such approach is widely used across JavaScript libraries. From 690c223335fc40a72bfa1614864a0ff9bea69af4 Mon Sep 17 00:00:00 2001 From: Tofpu <47629321+Tofpu@users.noreply.github.com> Date: Tue, 16 Nov 2021 09:52:12 +0200 Subject: [PATCH 02/12] added showStep to our chain in the solution --- .../04-object-methods/8-chain-calls/solution.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/04-object-basics/04-object-methods/8-chain-calls/solution.md b/1-js/04-object-basics/04-object-methods/8-chain-calls/solution.md index ab4e37340..f215461dd 100644 --- a/1-js/04-object-basics/04-object-methods/8-chain-calls/solution.md +++ b/1-js/04-object-basics/04-object-methods/8-chain-calls/solution.md @@ -23,7 +23,7 @@ let ladder = { } }; -ladder.up().up().down().up().down().showStep(); // 1 +ladder.up().up().down().showStep().down().showStep(); // shows 1 then 0 ``` We also can write a single call per line. For long chains it's more readable: @@ -33,7 +33,7 @@ ladder .up() .up() .down() - .up() + .showStep() // 1 .down() - .showStep(); // 1 + .showStep(); // 0 ``` From cf2ce5e6281fbd51dd526b2841d1c5ec43a5c119 Mon Sep 17 00:00:00 2001 From: Allen Date: Mon, 13 Dec 2021 09:47:54 +0800 Subject: [PATCH 03/12] Type: touch-events should be touch-action --- 2-ui/3-event-details/6-pointer-events/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/3-event-details/6-pointer-events/article.md b/2-ui/3-event-details/6-pointer-events/article.md index 4b58f3ffc..ef48dc335 100644 --- a/2-ui/3-event-details/6-pointer-events/article.md +++ b/2-ui/3-event-details/6-pointer-events/article.md @@ -271,7 +271,7 @@ Pointer events allow handling mouse, touch and pen events simultaneously, with a Pointer events extend mouse events. We can replace `mouse` with `pointer` in event names and expect our code to continue working for mouse, with better support for other device types. -For drag'n'drops and complex touch interactions that the browser may decide to hijack and handle on its own - remember to cancel the default action on events and set `touch-events: none` in CSS for elements that we engage. +For drag'n'drops and complex touch interactions that the browser may decide to hijack and handle on its own - remember to cancel the default action on events and set `touch-action: none` in CSS for elements that we engage. Additional abilities of pointer events are: From 974073b2555a922d454b75864b22971b6d5278f8 Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Mon, 13 Dec 2021 17:55:03 +0300 Subject: [PATCH 04/12] typeof --- 1-js/02-first-steps/05-types/article.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/1-js/02-first-steps/05-types/article.md b/1-js/02-first-steps/05-types/article.md index 9fba1d8ad..b7fbbf8d0 100644 --- a/1-js/02-first-steps/05-types/article.md +++ b/1-js/02-first-steps/05-types/article.md @@ -213,14 +213,7 @@ The `symbol` type is used to create unique identifiers for objects. We have to m The `typeof` operator returns the type of the argument. It's useful when we want to process values of different types differently or just want to do a quick check. -It supports two forms of syntax: - -1. As an operator: `typeof x`. -2. As a function: `typeof(x)`. - -In other words, it works with parentheses or without them. The result is the same. - -The call to `typeof x` returns a string with the type name: +A call to `typeof x` returns a string with the type name: ```js typeof undefined // "undefined" @@ -254,6 +247,14 @@ The last three lines may need additional explanation: 2. The result of `typeof null` is `"object"`. That's an officially recognized error in `typeof` behavior, coming from the 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. 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. +```smart header="The `typeof(x)` syntax" +You may also see another syntax in the code: `typeof(x)`. It's the same as `typeof x`. + +The parentheses here aren't a part of the `typeof` operator. It's the kind of parentheses used for mathematical grouping. 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. + +Some people prefer `typeof(x)`, although the `typeof x` syntax is much more common. +``` + ## Summary There are 8 basic data types in JavaScript. @@ -269,7 +270,7 @@ There are 8 basic data types in JavaScript. The `typeof` operator allows us to see which type is stored in a variable. -- Two forms: `typeof x` or `typeof(x)`. +- Usually used as `typeof x`, but `typeof(x)` is also possible. - Returns a string with the name of the type, like `"string"`. - For `null` returns `"object"` -- this is an error in the language, it's not actually an object. From 9a425777dd750b5ddccefd7edd4f72f13a485fc3 Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Mon, 13 Dec 2021 17:56:16 +0300 Subject: [PATCH 05/12] minor fixes --- 1-js/02-first-steps/05-types/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/05-types/article.md b/1-js/02-first-steps/05-types/article.md index b7fbbf8d0..404161b72 100644 --- a/1-js/02-first-steps/05-types/article.md +++ b/1-js/02-first-steps/05-types/article.md @@ -248,7 +248,7 @@ The last three lines may need additional explanation: 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. ```smart header="The `typeof(x)` syntax" -You may also see another syntax in the code: `typeof(x)`. It's the same as `typeof x`. +You may also come across another syntax in some code: `typeof(x)`. It's the same as `typeof x`. The parentheses here aren't a part of the `typeof` operator. It's the kind of parentheses used for mathematical grouping. 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. From b0e46f4fc0da0428662849e02a5c7c722ca1b65d Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Mon, 13 Dec 2021 18:29:17 +0300 Subject: [PATCH 06/12] minor fixes --- 1-js/02-first-steps/05-types/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/05-types/article.md b/1-js/02-first-steps/05-types/article.md index 404161b72..8d06011c9 100644 --- a/1-js/02-first-steps/05-types/article.md +++ b/1-js/02-first-steps/05-types/article.md @@ -244,7 +244,7 @@ typeof alert // "function" (3) The last three lines may need additional explanation: 1. `Math` is a built-in object that provides mathematical operations. We will learn it in the chapter . Here, it serves just as an example of an object. -2. The result of `typeof null` is `"object"`. That's an officially recognized error in `typeof` behavior, coming from the 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. +2. The result of `typeof null` 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. 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. ```smart header="The `typeof(x)` syntax" From 80148c07b1415a3c33124fe104d785bc4003eca0 Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Mon, 13 Dec 2021 18:29:36 +0300 Subject: [PATCH 07/12] minor fixes --- 1-js/02-first-steps/05-types/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/05-types/article.md b/1-js/02-first-steps/05-types/article.md index 8d06011c9..0bb349c8f 100644 --- a/1-js/02-first-steps/05-types/article.md +++ b/1-js/02-first-steps/05-types/article.md @@ -248,7 +248,7 @@ The last three lines may need additional explanation: 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. ```smart header="The `typeof(x)` syntax" -You may also come across another syntax in some code: `typeof(x)`. It's the same as `typeof x`. +You may also come across another syntax: `typeof(x)`. It's the same as `typeof x`. The parentheses here aren't a part of the `typeof` operator. It's the kind of parentheses used for mathematical grouping. 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. From 233d63c92792b53bbd75a8161c1ce3bec7c9f129 Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Mon, 13 Dec 2021 18:30:32 +0300 Subject: [PATCH 08/12] minor fixes --- 1-js/02-first-steps/05-types/article.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/1-js/02-first-steps/05-types/article.md b/1-js/02-first-steps/05-types/article.md index 0bb349c8f..975a0c1b6 100644 --- a/1-js/02-first-steps/05-types/article.md +++ b/1-js/02-first-steps/05-types/article.md @@ -250,7 +250,9 @@ The last three lines may need additional explanation: ```smart header="The `typeof(x)` syntax" You may also come across another syntax: `typeof(x)`. It's the same as `typeof x`. -The parentheses here aren't a part of the `typeof` operator. It's the kind of parentheses used for mathematical grouping. 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. +To put it clear: `typeof` is an operator, not a function. The parentheses here aren't a part of the `typeof`. It's the kind of parentheses used for mathematical grouping. + +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. Some people prefer `typeof(x)`, although the `typeof x` syntax is much more common. ``` From 4bd4a746d6234e303f67d61b0b1b2f9b78f599f6 Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Mon, 13 Dec 2021 18:31:16 +0300 Subject: [PATCH 09/12] minor fixes --- 1-js/02-first-steps/05-types/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/05-types/article.md b/1-js/02-first-steps/05-types/article.md index 975a0c1b6..ca9039aea 100644 --- a/1-js/02-first-steps/05-types/article.md +++ b/1-js/02-first-steps/05-types/article.md @@ -250,7 +250,7 @@ The last three lines may need additional explanation: ```smart header="The `typeof(x)` syntax" You may also come across another syntax: `typeof(x)`. It's the same as `typeof x`. -To put it clear: `typeof` is an operator, not a function. The parentheses here aren't a part of the `typeof`. It's the kind of parentheses used for mathematical grouping. +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. 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. From 98d590ba4a57efdc59b76aebee5366f76278b24d Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Mon, 13 Dec 2021 18:31:50 +0300 Subject: [PATCH 10/12] minor fixes --- 1-js/02-first-steps/05-types/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/05-types/article.md b/1-js/02-first-steps/05-types/article.md index ca9039aea..1b39265a4 100644 --- a/1-js/02-first-steps/05-types/article.md +++ b/1-js/02-first-steps/05-types/article.md @@ -254,7 +254,7 @@ To put it clear: `typeof` is an operator, not a function. The parentheses here a 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. -Some people prefer `typeof(x)`, although the `typeof x` syntax is much more common. +So, some people prefer `typeof(x)`, although the `typeof x` syntax is much more common. ``` ## Summary From 8d04d0d2db97276dbb2b451c30a7bd3e05d65831 Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Mon, 13 Dec 2021 18:31:56 +0300 Subject: [PATCH 11/12] minor fixes --- 1-js/02-first-steps/05-types/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/05-types/article.md b/1-js/02-first-steps/05-types/article.md index 1b39265a4..ca9039aea 100644 --- a/1-js/02-first-steps/05-types/article.md +++ b/1-js/02-first-steps/05-types/article.md @@ -254,7 +254,7 @@ To put it clear: `typeof` is an operator, not a function. The parentheses here a 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. -So, some people prefer `typeof(x)`, although the `typeof x` syntax is much more common. +Some people prefer `typeof(x)`, although the `typeof x` syntax is much more common. ``` ## Summary From 6157a73b56496af6c39ec52c951c98af181269e3 Mon Sep 17 00:00:00 2001 From: Osvaldo Dias dos Santos Date: Mon, 20 Dec 2021 23:17:08 +0100 Subject: [PATCH 12/12] Resolve conflicts --- 1-js/02-first-steps/05-types/article.md | 41 +++++-------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/1-js/02-first-steps/05-types/article.md b/1-js/02-first-steps/05-types/article.md index fb65b47c9..30a0da4e7 100644 --- a/1-js/02-first-steps/05-types/article.md +++ b/1-js/02-first-steps/05-types/article.md @@ -213,18 +213,7 @@ O tipo `symbol` é usado para criar identificadores únicos para objetos. Nós o 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. -<<<<<<< HEAD -Suporta duas formas de sintaxe: - -1. Como operador: `typeof x`. -2. Como uma função: `typeof(x)`. - -Em outras palavras, trabalha com parênteses ou sem eles. O resultado é o mesmo. - A chamada para `typeof x` retorna uma string com o nome do tipo: -======= -A call to `typeof x` returns a string with the type name: ->>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831 ```js typeof undefined // "undefined" @@ -254,29 +243,21 @@ typeof alert // "function" (3) As três últimas linhas podem precisar de explicações adicionais: -<<<<<<< HEAD 1. `Math` é um objeto embutido que fornece operações matemáticas. Nós o vamos aprender no capítulo . Aqui, ele serve apenas como um exemplo de um objeto. -2. O resultado de `typeof null` é `"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. +2. O resultado de `typeof null` é `"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. 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. -## Resumo -======= -1. `Math` is a built-in object that provides mathematical operations. We will learn it in the chapter . Here, it serves just as an example of an object. -2. The result of `typeof null` 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. -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. - -```smart header="The `typeof(x)` syntax" -You may also come across another syntax: `typeof(x)`. It's the same as `typeof x`. +```smart header="A `sintaxe typeof(x)`" +Você pode também encontrar outra sintaxe: `typeof(x)`. è o mesmo que `typeof x`. -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. +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. -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. +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. -Some people prefer `typeof(x)`, although the `typeof x` syntax is much more common. +Algumas pessoas preferem `typeof(x)`, embora a sintaxe `typeof x` seja muito mais comum. ``` -## Summary ->>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831 +## Resumo Existem 8 tipos básicos em JavaScript. @@ -291,14 +272,8 @@ Existem 8 tipos básicos em JavaScript. O operador `typeof` nos permite ver que tipo está armazenado em uma variável. -<<<<<<< HEAD -- Duas formas: `typeof x` ou `typeof(x)`. +- Geralmente, usado como `typeof x`, mas `typeof(x)` também é possivel. - Retorna uma string com o nome do tipo, como `"string"`. - Para `null` retorna `"object"` -- isso é um erro na linguagem, não é realmente um objeto. -======= -- Usually used as `typeof x`, but `typeof(x)` is also possible. -- Returns a string with the name of the type, like `"string"`. -- For `null` returns `"object"` -- this is an error in the language, it's not actually an object. ->>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831 Nos próximos capítulos, nos vamos concentrar nos valores primitivos e, uma vez familiarizados com eles, passaremos para os objetos.