Skip to main content
deleted 1 character in body; edited title
Source Link
Peilonrayz
  • 44.6k
  • 7
  • 80
  • 158

Is index access old school in frontend development? Returning the last segment of a split string

Tweeted twitter.com/StackCodeReview/status/1304479864892854281
Became Hot Network Question
Source Link

Is index access old school in frontend development?

I recently reviewed a PR and saw the following.

const parts = someString.split('.');
return parts[parts.length - 1];

was changed to

const [last] = someString.split('.').reverse();
return last;

I commented that I am against the change for the reasons that it is harder to read and not performant.

The answer was that it is only hard to read, because I am not used to it and that performance does not matter if you use big frameworks like React for example.

Who is right and why?