This post was originally published at kais.blog.
Let's move your learning forward together! Follow me on Twitter for your daily dose of developer ...
For further actions, you may consider blocking this person and/or reporting abuse
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
Boolean
Was about to suggest this as well. Much cleaner to me :-)
Please don't use emojis.
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 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) :)You can also do
[1, 2, 3, 4, null, 5, undefined].filter(Boolean)
to remove falsey values.Nice one! Thanks
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.