Category: PHP, javascript

One of the most important features of ES6 is https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment of arrays and objects. So, using destructuring its possible to unpack values from arrays, or properties from objects, into distinct variables like so. const [firstName, lastName, age] = ['Cherika', 'Merchant', 5]; firstName; // 'Cherika' lastName; // 'Merchant' age; // 5 #the-problem #choosing-a-specific-index

And because of this, if you only want to retrieve say lastName, you would need to do something like this. const [, lastName,] = ['Cherika', 'Merchant', 5]; lastName; // 'Merchant'
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners