Skip to content
This repository has been archived by the owner on May 15, 2022. It is now read-only.

Commit

Permalink
Atuializado Resumo
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarcon83 committed Mar 28, 2021
1 parent edeac3b commit d2b18c7
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions _JS - ES 6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Spread operator
da mesma separados por vírgula;


Destructiruing
Destructuring

Retorna os valores dos itens de arrays ou objetos de maneira mais
simples.
Expand All @@ -28,14 +28,22 @@ Destructiruing
const obj = {x:4, y:6, z:8};

let [a, b] = [1 , 2] // a = 1; b =2;

let [c, d] = nums // c = 5; d = 7;

let [e, ...f] = nums // e = 5; f = [7, 9, 11];

let [g,,,h] = nums // g = 5; h = 11;
let {y, z} = obj // y = 6; z = 8;

Podemos usar a seguinte sintaxe para mudar o nome da
variável:
Podemos usar diretamente um uma função:

const fooName = ({x,z}) => etc...

fooName(obj) // vai ter x = 4 e z = 8;

Podemos usar a seguinte sintaxe para mudar o nome da variável:

let {z: novoZ} = obj // novoZ = 8;

String literal

let {novoZ: z} = obj // novoZ = 8;
Usamos ` no lugar das aspas, com ${varName} podemos inserir variáveis
aceita também enter para separar as linhas.

0 comments on commit d2b18c7

Please sign in to comment.