chrome-extension-boilerplate-react-vite
chrome-extension-boilerplate-react-vite copied to clipboard
:zap: using internal function
using internal function Array.pop() to get the last element of array, removed getLastElement()
@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.
No further comments, so I'm closing.
Using internal function Array.prototype.at() to get the last element of array.
[1, 2, 3].at(-1);
// 3