DEV Community

Emerson Brôga Dev
Emerson Brôga Dev

Posted on

2 2

Invertendo valores com o Destructuring Assignment

Invertendo valores com o Destructuring Assignment

Usando o destructuring você consegue facilmente inverter valores de váriaveis.

Vamos supor que você tenha let a = 1 e let b = 2, você consegue facilmente
inverter os valores, fazendo com que o a = 2 e o b = 1, usando apenas:

let a = 1;
let b = 2;
[a, b] = [b, a];
// a será 2
// b será 1
Enter fullscreen mode Exit fullscreen mode

=)

➜ Participe da nossa lista de desenvolvedores
➜ Aprenda ES6
➜ Veja as dicas no instagram
➜ Assita nosso canal no Youtube
➜ Curta nossa página no facebook
➜ Não perca as atualizações no twitter

#javascript #react #node #es6

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Postgres on Neon - Get the Free Plan

No credit card required. The database you love, on a serverless platform designed to help you build faster.

Get Postgres on Neon

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay