✅ – ✅ – ✅ – dmikester1 – 18-03 Sep 25
Is there an easy way to filter this array by truthy values?
14 Replies
Maybe I should change my objects to look like:
{type: 'standard', value: true}
?Solution
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
This question has an answer! Thank you for helping 😄
If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1155927650322366534
This question has an answer! Thank you for helping 😄
If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1155927650322366534
Makes sense, thank you!
Like that
typesArr.filter(Boolean)
?
Oh, wait there are objects
aw, ok, what does 'length' do?
length
prop returns the length of array and if it is empty, length
returns 0 and filter
would skip that element from output arrayoh interesting, that is cool way to do it! Never would have thought of that, thanks!
This question has an answer! Thank you for helping 😄
If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1155927650322366534
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
Why only check for 1 prop, when there is no certainty that other props may be truthy/falsy 🤔
I mean, it depend on the input structure
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
Okay, fair point. I've hoped that was only an example and final data is bigger 😅
This thread hasn’t had any activity in 36 hours, so it’s now locked.
Threads are closed automatically after 36 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1155927650322366534