An Interest In:
Web News this Week
- April 2, 2024
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
January 18, 2019 03:13 pm GMT
Original Link: https://doesitmutate.xyz/
Does it mutate?
This little site by Remy Sharp's makes it clear whether or not a JavaScript method changes the original array (aka mutates) or not.
I was actually bitten by this the other day. I needed the last element from an array, so I remembered .pop()
and used it.
const arr = ["doe", "ray", "mee"];const last = arr.pop();// mee, but array is now ["doe", "ray"]
This certainly worked great right away, but I didn't realize the original array had changed … Read article
The post Does it mutate? appeared first on CSS-Tricks.
Original Link: https://doesitmutate.xyz/
Share this article:
Tweet
View Full Article