Destructuring y spread
Sacar varios valores de un objeto de una vez, y copiar listas sin bucles. Dos atajos que vas a usar todos los días.
Destructuring and spread
Pulling several values out of an object at once, and copying lists without loops. Two shortcuts you will use every day.
Ya sabes sacar un dato de un objeto con jugador.nombre. Si necesitas varios a
la vez, el destructuring te ahorra repetir el nombre del objeto una y otra
vez.
You already know how to get a value from an object with jugador.nombre. If you
need several at once, destructuring saves you from repeating the object's
name over and over.
Con un array funciona parecido, pero acá sí importa el orden: se asigna por posición, con corchetes en vez de llaves.
With an array it works similarly, but here order does matter: it assigns by position, using brackets instead of braces.
Los tres puntos ... son el operador spread: toma todos los
elementos de un array u objeto y los "desparrama" sueltos. Sirve para copiar o combinar sin
bucles.
Three dots ... are the spread operator: it takes every item
of an array or object and "spreads" them loose. It is used to copy or combine without
loops.
Los mismos tres puntos, usados al revés, se llaman rest: juntan "todo lo que sobra" en un array. Es lo opuesto a spread.
The same three dots, used the other way around, are called rest: they gather "everything left over" into an array. It is the opposite of spread.
Sacar varios valores de un objeto o array con destructuring, copiar y combinar con spread sin mutar el original, y juntar argumentos sueltos con rest.
Ahora un tema que confunde bastante al principio: cómo escriben las funciones flecha, y qué es eso de "this".
Pulling several values from an object or array with destructuring, copying and combining with spread without mutating the original, and gathering loose arguments with rest.
Now a topic that trips up a lot of beginners: how arrow functions are written, and what this "this" thing is.