Some Array destructuring tricks. #shorts

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

"[They] were so preoccupied with whether or not they could that they didn't stop to think if they should."

dv_interval
Автор

I think that's elegant. You have one paradigm. You can conceptualize a JavaScript object as an array or as a dictionary or as a list, and you can just use one set of common syntax to manipulate any kind of object. Why waste time learning three different kinds of syntax to manipulate what is fundamentally the same kind of thing to the computer? If you need the performance of actually using a different kind of data structure, JavaScript probably isn't the tool you need for the job you are trying to do.

richardrisner
Автор

definitely gonna use the last one.. finding the middle of an array.

Yeasiin
Автор

On the one-hand, *cool*.
On the other - This would be a nightmare to read and make sense of X-P

r-i-ch
Автор

Initial thought when first seeing this was "DA F*** does he destructure 'length' for?"

But yeah, ARRAYS ARE OBJECTS - so {length} will of course refer to the Array.prototype.length property 😅

christian-schubert
Автор

People, please don't do this. Do it the right, more readable way

AndersonSilvaMMA