# Destructuring an array from a function in JavaScript

The array for destructuring does not have to be stored in a variable. It can also be the result of a function. Let's look at an example. Let the following function be given:

`function func() { return [2025, 12, 31]; }`

Destructuring the value returned by this function:

`let [year, month, day] = func();`

In the following code, parts of the array are written to the corresponding variables:

`function func() { return ['John', 'Smit', 'development', 'programmer', 2000]; } let arr = func(); let name = arr[0]; let surname = arr[1]; let department = arr[2]; let position = arr[3]; let salary = arr[4];`

Rework this code through destructuring according to the learned theory.

← →
↑
en ru