DEV Community

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

Collapse
 
ironcladdev profile image
IroncladDev

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

Collapse
 
tentoumushi profile image
てんとう虫 🐞

No, I am completely serious.

Collapse
 
ironcladdev profile image
IroncladDev

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.