chrome-extension-boilerplate-react-vite icon indicating copy to clipboard operation
chrome-extension-boilerplate-react-vite copied to clipboard

:zap: using internal function

Open oviirup opened this issue 2 years ago • 1 comments

using internal function Array.pop() to get the last element of array, removed getLastElement()

oviirup avatar Aug 25 '22 10:08 oviirup

@graygalaxy

Thank you for your contribution.

In my opinion, getLastElement() and Array.prototype.pop() are functions that do different actions.

I personally prefer the copy on write technique as a way to be more predictable and avoid side effects, and getLastElement() is the appropriate way to do so. On the other hand, I think the Array.prototype.pop() method unnecessarily creates modifications to existing arrays, creating more unpredictable elements in maintenance.

Please give us your opinion or feedback on this part.

Jonghakseo avatar Aug 30 '22 01:08 Jonghakseo

No further comments, so I'm closing.

Jonghakseo avatar Sep 18 '22 11:09 Jonghakseo

Using internal function Array.prototype.at() to get the last element of array.

[1, 2, 3].at(-1);
// 3

ltyocg avatar Nov 06 '22 12:11 ltyocg