Kaemon Lovendahl, Logic Warlock of the 15th Realm of Remotia, Master of Tests and Documentation, Manipulator of Logic, Devourer of Bugs, Champion of the Great Hall of Objects.
You should probably write that copying array/object with spread operator/slice/object.assign/json technique is just shallow copying - which is important information. Also you can use Object.assign([], [your array]) and another one JSON.parse(JSON.stringify([your array])) (but I would not recommend it to you) :)
An easier way to copy an array:
I was also looking if this method is mentioned in the article.
Thank you for the nice tips!
You can also use simple coercion to
BooleanWas about to suggest this as well. Much cleaner to me :-)
When your browser doesn't render emojis you get Replacement Glyph.
Thanks for your feedback! What browser are you using?
Latest Chrome on Win7 with almost all fonts deleted.
You can also do
[1, 2, 3, 4, null, 5, undefined].filter(Boolean)to remove falsey values.You should probably write that copying array/object with spread operator/slice/object.assign/json technique is just shallow copying - which is important information. Also you can use
Object.assign([], [your array])and another oneJSON.parse(JSON.stringify([your array]))(but I would not recommend it to you) :)awesome tips
Absolutely amazing. I've started learning react and I noticed that I'll be dealing with arrays of different sorts. This article is quite helpful.
Nice one! Thanks