# Default functions when destructuring an array in JavaScript

You can also specify a function as the default value. Let, for example, we have a function that returns the current day of the week:

`function func() { return (new Date).getDate(); }`

Let's specify this function as the value of the variable `day`:

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

Modify the code obtained above so that if there is no value for the month in the array, the current month is taken by default, and if there is no value for the year, the current year is taken accordingly.

←→
↑
en ru