3 ms·
> It has the same fundamental function. No, it doesn't. > JS just has the concept of "false-ish", which you'll likely already know as a JS developer. Ruby ha
by dragonwriter 7y ago
> It has the same fundamental function.
No, it doesn't.
> JS just has the concept of "false-ish", which you'll likely already know as a JS developer.
Ruby has a concept of false-ish (which is narrower than JS’s), but Ruby’s “compact” isn't about false-ish-ness, Filtering out false-ish values is .select(&:itself), not .compact
- ceejayoz 7y agoMaybe my feelings here are colored by PHP being my primary lang, but I read both functions purpose as "remove the empty values from this array" with a language-level difference on what "empty" is defined as. PHP's "empty" includes both nulls and false-y values. Whether you want to call it the "same" function or "similar" function, lodash's excellent docs reveal its functionality quite handily if someone's confused by it.