Skip to content

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

@koin612

Description

@koin612

hey,

I used deepdash's filterdeep method and wrote a predicate which evaluates a boolean expression like

(val, key, parent) => key === 'key' && (val === 'val1' || val === 'val2')

this doesnt work the result would be null, but if I explicit return true everything is fine (like in the official examples).

(val, key, parent) => { if (...) return true }

So, from the docs (https://deepdash.io/#iteratee) I figured out that this is because of "returns - return false explicitly to prevent iteration over current value's children"?

Is my assumption correct and what is this called in JS? I'd like to know more about this but I fail to find anything related to this. Can someone explain or point out some words so I can check?

Edit: I now think it's because it works with undefined for seen nodes so just returning true/false would not work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions