06 Feb 2023
Assign values to multiple variables in an array by the result of evaluation
[firstName, lastName] = fullName.split(' ')
Example
let firstName = '';
let lastName = '';
[firstName, lastName] = 'John Doe'.split(' ')
console.log(firstName) // John
console.log(lastName) // Doe
Get in touch_