DEV Community

Discussion on: How To Efficiently Get The Last Element Of An Array In JavaScript

Collapse
 
ironcladdev profile image
Conner Ow

Epicly terrible and absolutely inefficient way. Please tell me you're joking.

Collapse
 
reservecrate profile image
Aldi Kabulov

No, I am completely serious.

Collapse
 
ironcladdev profile image
Conner Ow

For...of loops are proven to perform way slower than for(var i = 0; i < x; i++) normal for loops and for you to perform that operation thrice, it's gonna slow down your code dramatically.

Okay forget it, I literally am just not gonna talk to an absolute imbecile here. You wanna do it this way, then do it.