Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 18, 2019 03:13 pm GMT

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:    Share on Facebook
View Full Article

CSS Tricks

A Web Design Community curated by Chris Coyier

More About this Source Visit CSS Tricks