Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
ES6 Destructuring | Getting Started: ES6
Introduction to React
course content

Conteúdo do Curso

Introduction to React

Introduction to React

1. Getting Started: ES6
2. Getting Started: JSX
3. React in Practice
4. React Components
5. Controlling Data & Content
6. Hooks
7. React Router

bookES6 Destructuring

The older method of accessing and assigning values from an array was indexing:

However, ES6 has introduced a new method called destructuring, which enables us to access and assign values from an array easily:

The above method is much neater and requires less code.

We can also skip the elements we don't want to capture, for example, we can skip airVehicle but add an extra comma:

Note

The const keyword is for defining constant terms, you can also use the let keyword in the Destructuring statement.

question-icon

Complete the following code:

function stringVariants (str) {
    return [str.toLowerCase (), str.toUpperCase ()];
}
[,] = stringVariants ("Hello World!");
console.log (lower, upper);
hello world! HELLO WORLD!

Clique ou arraste solte itens e preencha os espaços

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 6
some-alt