Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8c7b981
Add information about virtual/mobile keyboards and an additional keyb…
Danziger Nov 28, 2020
7b21346
Typos + rephrasing
RapTho Dec 14, 2020
7a7b25a
small rephrasings
RapTho Dec 14, 2020
9f2d200
Update 2-ui/3-event-details/7-keyboard-events/article.md
Danziger Dec 14, 2020
dfa5ec9
small reformulation
RapTho Dec 14, 2020
9a84c51
Fixed small typos
RapTho Dec 14, 2020
3a21dce
Add link to Kotlin/JS
tokou Dec 16, 2020
0427ecb
Reformulations
RapTho Dec 17, 2020
1af33d1
Give me five
joaquinelio Dec 20, 2020
5a14316
Update article.md
joaquinelio Dec 20, 2020
fc3f811
Merge pull request #2399 from joaquinelio/patch-2
iliakan Dec 20, 2020
f3555ee
fixed small typos
nazar-bodan Dec 20, 2020
13da056
closes #2401
iliakan Dec 22, 2020
cbdc268
Update article.md
imaverage Dec 24, 2020
33e25dc
Update article.md
Georgy-Losenkov Dec 25, 2020
83b051e
Change source of the term 'microtask'
raycon Dec 31, 2020
701392c
Merge pull request #2413 from raycon/master
iliakan Dec 31, 2020
6418344
closes #2411
iliakan Dec 31, 2020
2754e03
closes #2410
iliakan Dec 31, 2020
1404669
Merge pull request #2406 from Georgy-Losenkov/patch-1
iliakan Dec 31, 2020
b7d2820
Merge pull request #2391 from RapTho/patch-6
iliakan Dec 31, 2020
b0aa994
Merge pull request #2400 from wolfter12/fixed-small-typos
iliakan Dec 31, 2020
1fa08bc
Merge pull request #2404 from imaverage/patch-1
iliakan Dec 31, 2020
cc593c6
Update article.md
LLyaudet Dec 31, 2020
02089cf
Merge pull request #2393 from tokou/patch-1
iliakan Dec 31, 2020
98de4f4
Merge pull request #2386 from RapTho/patch-2
iliakan Dec 31, 2020
4a0da59
Merge pull request #2414 from LLyaudet/patch-2
iliakan Dec 31, 2020
b9481da
Edits based on feedback iliakan
RapTho Jan 2, 2021
bcbb5d5
Edit based on feedback iliakan
RapTho Jan 2, 2021
03b6d86
Edit based on feedback iliakan
RapTho Jan 2, 2021
04b1313
Remove keyjs.dev link under the key codes inspection snippet.
Danziger Jan 3, 2021
039716d
Merge pull request #2389 from Danziger/patch-1
iliakan Jan 3, 2021
16ac397
kotlin 404
joaquinelio Jan 4, 2021
e730c5a
Merge pull request #2416 from joaquinelio/patch-1
iliakan Jan 4, 2021
c67f8b8
Merge pull request #2388 from RapTho/patch-4
iliakan Jan 4, 2021
51f3915
Merge pull request #2390 from RapTho/patch-5
iliakan Jan 4, 2021
42ee148
Merge pull request #2395 from RapTho/patch-8
iliakan Jan 4, 2021
c350514
minor
iliakan Jan 7, 2021
32518b7
minor
iliakan Jan 7, 2021
80c4901
all operators must return a value
lumosmind Jan 7, 2021
a2561dc
Minor output typo
TaylorClay Jan 7, 2021
2229a48
Update article.md
martynov-94 Jan 8, 2021
5965ae7
Update currying function to use bind instead of wrapper pass
lakbychance Jan 9, 2021
997f392
Add the (2) point reference
lakbychance Jan 9, 2021
3b7d493
closes #2421
iliakan Jan 9, 2021
18a60ab
Merge pull request #2420 from martynov-94/patch-1
iliakan Jan 9, 2021
930485b
Merge pull request #2419 from TaylorClay/patch-1
iliakan Jan 9, 2021
12b23c7
Merge pull request #2417 from lumosmind/patch-55
iliakan Jan 9, 2021
6113f33
Merge pull request #2422 from lapstjup/patch-1
iliakan Jan 9, 2021
2027939
minor fixes
iliakan Jan 9, 2021
6a432df
parameters are also local variables
lumosmind Jan 9, 2021
86a6021
minor fixes
iliakan Jan 10, 2021
468e355
Merge pull request #2423 from lumosmind/patch-56
iliakan Jan 10, 2021
e476284
merging all conflicts
iliakan Jan 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions 1-js/01-getting-started/1-intro/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,20 @@ Las herramientas modernas hacen la conversión (Transpilation) muy rápida y tra

Ejemplos de tales lenguajes:

<<<<<<< HEAD
- [CoffeeScript](http://coffeescript.org/) Es una "sintaxis azucarada" para JavaScript. Introduce una sintaxis corta, permitiéndonos escribir un código mas claro y preciso. Usualmente desarrolladores de Ruby prefieren este lenguaje.
- [TypeScript](http://www.typescriptlang.org/) se concentra en agregar "tipado estricto" ("strict data typing") para simplificar el desarrollo y soporte de sistemas complejos. Es desarrollado por Microsoft.
-[FLow](https://flow.org/) también agrega la escritura de datos, pero de una manera diferente. Desarrollado por Facebook.
- [Dart](https://www.dartlang.org/) es un lenguaje independiente que tiene su propio motor que se ejecuta en entornos que no son de navegador (como aplicaciones móviles), pero que también se puede convertir/transpilar a JavaScript. Desarrollado por Google.
- [Brython](https://brython.info/) es un transpilador de Python a JavaScript que permite escribir aplicaciones en Python puro sin JavaScript.
=======
- [CoffeeScript](http://coffeescript.org/) is a "syntactic sugar" for JavaScript. It introduces shorter syntax, allowing us to write clearer and more precise code. Usually, Ruby devs like it.
- [TypeScript](http://www.typescriptlang.org/) is concentrated on adding "strict data typing" to simplify the development and support of complex systems. It is developed by Microsoft.
- [Flow](http://flow.org/) also adds data typing, but in a different way. Developed by Facebook.
- [Dart](https://www.dartlang.org/) is a standalone language that has its own engine that runs in non-browser environments (like mobile apps), but also can be transpiled to JavaScript. Developed by Google.
- [Brython](https://brython.info/) is a Python transpiler to JavaScript that enables the writing of applications in pure Python without JavaScript.
- [Kotlin](https://kotlinlang.org/docs/reference/js-overview.html) is a modern, concise and safe programming language that can target the browser or Node.
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

Hay más. Por supuesto, incluso si nosotros usamos alguno de estos lenguajes, deberíamos conocer también JavaScript para realmente entender qué estamos haciendo.

Expand Down
4 changes: 4 additions & 0 deletions 1-js/02-first-steps/08-operators/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ alert( x ); // 5

El hecho de que `=` sea un operador, no un construcción "mágica" del lenguaje, tiene un implicanción interesante.

<<<<<<< HEAD
La mayoría de los operadores en JavaScript devuelven un valor. Esto es obvio para `+` y `-`, pero también es cierto para `=`.
=======
All operators in JavaScript return a value. That's obvious for `+` and `-`, but also true for `=`.
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

La llamada `x = value` escribe el `value` en `x` *y luego lo devuelve*.

Expand Down
6 changes: 6 additions & 0 deletions 1-js/02-first-steps/18-javascript-specials/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,15 @@ Cubrimos tres formas de crear una función en JavaScript:
```


<<<<<<< HEAD
- Las funciones pueden tener variables locales: aquellas declaradas dentro de su cuerpo. Estas variables solo son visibles dentro de la función.
- Los parámetros pueden tener valores predeterminados: `function sum(a = 1, b = 2) {...}`.
- Las funciones siempre devuelven algo. Si no hay `return`, entonces el resultado es `undefined`.
=======
- Functions may have local variables: those declared inside its body or its parameter list. Such variables are only visible inside the function.
- Parameters can have default values: `function sum(a = 1, b = 2) {...}`.
- Functions always return something. If there's no `return` statement, then the result is `undefined`.
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

Más: ver <info:function-basics>, <info:arrow-functions-basics>.

Expand Down
9 changes: 9 additions & 0 deletions 1-js/03-code-quality/01-debugging-chrome/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,16 @@ Hay botones para esto en le panel superior derecho. Revisémoslos.

Esto es lo que podemos ver al hacer click:

<<<<<<< HEAD
![](chrome-sources-debugger-trace-1.svg)
=======
<span class="devtools" style="background-position:-62px -192px"></span> -- "Step over": run the next command, but *don't go into a function*, hotkey `key:F10`.
: Similar to the previous "Step" command, but behaves differently if the next statement is a function call. That is: not a built-in, like `alert`, but a function of our own.

The "Step" command goes into it and pauses the execution at its first line, while "Step over" executes the nested function call invisibly, skipping the function internals.

The execution is then paused immediately after that function.
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

La ejecución continuó, alcanzando el siguiente breakpoint dentro de `say()` y pausándose allí. Revisa el "Call stack" a la derecha. Ha incrementado su valor una llamada. Ahora estamos dentro de `say()`.

Expand Down
4 changes: 4 additions & 0 deletions 1-js/04-object-basics/07-optional-chaining/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,8 @@ Como podemos ver, todos ellos son sencillos y fáciles de usar. El `?.` comprueb

Una cadena de `?.` permite acceder de forma segura a las propiedades anidadas.

<<<<<<< HEAD
Aún así, debemos aplicar `?.` con cuidado, solo donde está bien que la parte izquierda no exista. Para que no nos oculte errores de programación, si ocurren.
=======
Still, we should apply `?.` carefully, only where it's acceptable that the left part doesn't exist. So that it won't hide programming errors from us, if they occur.
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f
8 changes: 8 additions & 0 deletions 1-js/05-data-types/02-number/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,11 @@ JavaScript tiene un objeto incorporado [Math](https://developer.mozilla.org/es/d
Unos ejemplos:

`Math.random()`
<<<<<<< HEAD
: Devuelve un número aleatorio entre 0 y 1 (no incluyendo 1)
=======
: Returns a random number from 0 to 1 (not including 1).
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

```js run
alert( Math.random() ); // 0.1234567894322
Expand All @@ -400,7 +404,11 @@ Unos ejemplos:
```

`Math.pow(n, power)`
<<<<<<< HEAD
: Devuelve `n` elevado a la potencia `power` dada
=======
: Returns `n` raised to the given power.
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

```js run
alert( Math.pow(2, 10) ); // 2 elevado a la potencia de 10 = 1024
Expand Down
4 changes: 4 additions & 0 deletions 1-js/05-data-types/06-iterable/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ Pero un iterable puede no ser array-like. Y viceversa, un array-like puede no se

Por ejemplo, `range` en el ejemplo anterior es iterable, pero no array-like, porque no tiene propiedades indexadas ni `longitud` o *length*.

<<<<<<< HEAD
=======
But an iterable may be not array-like. And vice versa an array-like may be not iterable.
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

Y aquí está el objeto que tiene forma de matriz, pero no es iterable:

Expand Down
136 changes: 127 additions & 9 deletions 1-js/05-data-types/10-destructuring-assignment/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,38 @@

Las dos estructuras de datos más usadas en JavaScript son `Objetos` y `Array`.

<<<<<<< HEAD
Los objetos nos permiten crear una entidad individual que almacena elementos de información por propiedad, y los arrays nos permiten reunir elementos de información en una colección ordenada.

Pero cuando pasamos estos a una función, tal vez no necesite un objeto/array como un conjunto, sino más bien piezas individuales.

*Asignación Desestructurante* es una sintaxis especial que nos permite "vaciar" arrays u objetos en varias variables, ya que esto a veces es más conveniente. La desestructuración también funciona bien con funciones complejas que tienen muchos argumentos, valores por defecto, etcétera.
=======
- Objects allow us to create a single entity that stores data items by key.
- Arrays allow us to gather data items into an ordered list.

Although, when we pass those to a function, it may need not an object/array as a whole. It may need individual pieces.

*Destructuring assignment* is a special syntax that allows us to "unpack" arrays or objects into a bunch of variables, as sometimes that's more convenient.

Destructuring also works great with complex functions that have a lot of parameters, default values, and so on. Soon we'll see that.
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

## Desestructuración de Arrays

<<<<<<< HEAD
Un ejemplo de cómo el array es desestructurado en variables:

```js
// tenemos un array con el nombre y apellido
let arr = ["Ilya", "Kantor"]
=======
Here's an example of how an array is destructured into variables:

```js
// we have an array with the name and surname
let arr = ["John", "Smith"]
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

*!*
// asignación desestructurante
Expand All @@ -23,20 +42,29 @@ let arr = ["Ilya", "Kantor"]
let [firstName, surname] = arr;
*/!*

alert(firstName); // Ilya
alert(surname); // Kantor
alert(firstName); // John
alert(surname); // Smith
```

Ahora podemos trabajar con variables en lugar de miembros de array.

Se ve genial cuando se combina con `split` u otro método que devuelva un array:

```js
let [firstName, surname] = "Ilya Kantor".split(' ');
```js run
let [firstName, surname] = "John Smith".split(' ');
alert(firstName); // John
alert(surname); // Smith
```

<<<<<<< HEAD
````smart header="\"Desestructuración\" no significa \"destructivo\"."
Se llama "asignación desestructurante," porque "desestructura" al copiar elementos dentro de variables. Pero el array en sí no es modificado.
=======
As you can see, the syntax is simple. There are several peculiar details though. Let's see more examples, to better understand it.

````smart header="\"Destructuring\" does not mean \"destructive\"."
It's called "destructuring assignment," because it "destructurizes" by copying items into variables. But the array itself is not modified.
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

Es sólo una manera más simple de escribir:
```js
Expand Down Expand Up @@ -69,27 +97,38 @@ En el código de arriba, el segundo elemento del array es omitido, el tercero es
let [a, b, c] = "abc"; // ["a", "b", "c"]
let [one, two, three] = new Set([1, 2, 3]);
```

That works, because internally a destructuring assignment works by iterating over the right value. It's kind of syntax sugar for calling `for..of` over the value to the right of `=` and assigning the values.
````


<<<<<<< HEAD
````smart header="Asignar a cualquier cosa en el lado izquierdo"

Podemos usar cualquier "asignable" en el lado izquierdo.
=======
````smart header="Assign to anything at the left-side"
We can use any "assignables" at the left side.
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

Por ejemplo, una propiedad de objeto:
```js run
let user = {};
[user.name, user.surname] = "Ilya Kantor".split(' ');
[user.name, user.surname] = "John Smith".split(' ');

alert(user.name); // Ilya
alert(user.name); // John
alert(user.surname); // Smith
```

````

<<<<<<< HEAD
````smart header="Bucle con .entries()"

En el capítulo anterior vimos el método [Object.entries(obj)](mdn:js/Object/entries).
=======
````smart header="Looping with .entries()"
In the previous chapter we saw the [Object.entries(obj)](mdn:js/Object/entries) method.
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

Podemos usarlo con la desestructuración para recorrer propiedades-y-valores de un objeto:

Expand All @@ -107,14 +146,19 @@ for (let [key, value] of Object.entries(user)) {
}
```

<<<<<<< HEAD
...Y lo mismo para map:
=======
The similar code for a `Map` is simpler, as it's iterable:
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

```js run
let user = new Map();
user.set("name", "John");
user.set("age", "30");

*!*
// Map iterates as [key, value] pairs, very convenient for destructuring
for (let [key, value] of user) {
*/!*
alert(`${key}:${value}`); // name:John, luego age:30
Expand All @@ -123,27 +167,83 @@ for (let [key, value] of user) {
````
### El resto '...'

<<<<<<< HEAD
Si queremos no sólo obtener los primeros valores, pero también reunir todo lo que sigue -- podemos agregar un argumento más que obtiene "el resto" utilizando tres puntos `"..."`:
=======
````smart header="Swap variables trick"
There's a well-known trick for swapping values of two variables using a destructuring assignment:

```js run
let [name1, name2, *!*...rest*/!*] = ["Julius", "Caesar", *!*"Consul", "of the Roman Republic"*/!*];
let guest = "Jane";
let admin = "Pete";

// Let's swap the values: make guest=Pete, admin=Jane
*!*
[guest, admin] = [admin, guest];
*/!*

alert(`${guest} ${admin}`); // Pete Jane (successfully swapped!)
```

Here we create a temporary array of two variables and immediately destructure it in swapped order.

We can swap more than two variables this way.
````

### The rest '...'

Usually, if the array is longer when the list at the left, the "extra" items are omitted.

For example, here only two items are taken, and the rest is just ignored:
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

```js run
let [name1, name2] = ["Julius", "Caesar", "Consul", "of the Roman Republic"];

alert(name1); // Julius
alert(name2); // Caesar
// Furher items aren't assigned anywhere
```

If we'd like also to gather all that follows -- we can add one more parameter that gets "the rest" using three dots `"..."`:

```js run
let [name1, name2, *!*...rest*/!*] = ["Julius", "Caesar", *!*"Consul", "of the Roman Republic"*/!*];

*!*
<<<<<<< HEAD
// Notar que el tipo de `rest` es Array.
alert(resto[0]); // Consul
alert(resto[1]); // of the Roman Republic
=======
// rest is array of items, starting from the 3rd one
alert(rest[0]); // Consul
alert(rest[1]); // of the Roman Republic
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f
alert(rest.length); // 2
*/!*
```

<<<<<<< HEAD
El valor de `rest` es un array de los elementos restantes. Podemos usar cualquier otro nombre de variable en lugar de `rest`, sólo hay que asegurar que tenga tres puntos que lo antecedan y que esté último en la asignación desestructurante.
=======
The value of `rest` is the array of the remaining array elements.

We can use any other variable name in place of `rest`, just make sure it has three dots before it and goes last in the destructuring assignment.

```js run
let [name1, name2, *!*...titles*/!*] = ["Julius", "Caesar", "Consul", "of the Roman Republic"];
// now titles = ["Consul", "of the Roman Republic"]
```
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

### Valores predeterminados

<<<<<<< HEAD
Si hay menor cantidad de valores en el array que variables en la asignación, no habrá error. Valor ausentes son considerados undefined:
=======
If the array is shorter than the list of variables at the left, there'll be no errors. Absent values are considered undefined:
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

```js run
*!*
Expand All @@ -168,7 +268,11 @@ alert(surname); // Anonymous (predeterminado utilizado)

Los valores predeterminados pueden ser más complejos o incluso llamadas de función. Son evaluados sólo si el valor no ha sido proporcionado.

<<<<<<< HEAD
Por ejemplo, aquí utilizamos la función `prompt` para dos valores predeterminados. Pero sólo se ejecutará para el valor faltante:
=======
For instance, here we use the `prompt` function for two defaults:
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

```js run
// sólo ejecuta la captura para surname
Expand All @@ -178,7 +282,7 @@ alert(name); // Julius (desde array)
alert(surname); // lo que reciba la captura
```


Please note: the `prompt` will run only for the missing value (`surname`).

## Desestructuración de Objeto

Expand All @@ -190,7 +294,11 @@ La sintaxis básica es:
let {var1, var2} = {var1:…, var2:…}
```

<<<<<<< HEAD
Tenemos un objeto existente en el lado derecho, que queremos dividir en variables. El lado izquierdo contiene un "patrón" para propiedades correspondientes. En el caso simple, esto es una lista de nombre de variables en `{...}`.
=======
We should have an existing object at the right side, that we want to split into variables. The left side contains an object-like "pattern" for corresponding properties. In the simplest case, that's a list of variable names in `{...}`.
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

Por ejemplo:

Expand All @@ -210,7 +318,13 @@ alert(width); // 100
alert(height); // 200
```

<<<<<<< HEAD
Las propiedades `options.title`, `options.width` y `options.height` son asignadas a las variables correspondientes. El órden no importa. Esto también funciona:
=======
Properties `options.title`, `options.width` and `options.height` are assigned to the corresponding variables.

The order does not matter. This works too:
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

```js
// cambiado el órden en let {...}
Expand All @@ -219,7 +333,11 @@ let {height, width, title} = { title: "Menu", height: 200, width: 100 }

El patrón de la izquierda puede ser más complejo y especificar el mapeo entre propiedades y variables.

<<<<<<< HEAD
Si queremos asignar una propiedad a una variable con otro nombre, por ejemplo, `options.width` que vaya en la variable llamada `w`, entonces la podemos fijar usando dos puntos:
=======
If we want to assign a property to a variable with another name, for instance, make `options.width` go into the variable named `w`, then we can set the variable name using a colon:
>>>>>>> 468e3552884851fcef331fbdfd58096652964b5f

```js run
let options = {
Expand Down
Loading