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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners