Skip to content

explicit return values, why and how does this work #92

Answered by YuriGor
koin612 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, looks like you mixing docs for eachDeep and filterDeep.

eachDeep will not care about returned value unless it's exactly boolean false.
In this case eachDeep will skip current children if any, so it's kind of 'break' in for loop, but local for current depth level.
This is similar to convention of Lodash each method.

filterDeep similar to Lodash or native array filter method expects true or false from predicate to decide keep current value or not.
Because filterDeep case is much more complex, I extended this convention and also accept undefined as possible return result. If "truthy" reply will be "yes" and "falsey" response will be "no", undefined means "Don't know yet"

In case of undef…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@koin612
Comment options

@YuriGor
Comment options

Answer selected by koin612
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #90 on March 10, 2021 10:47.