jquery - JavaScript: filter() for Objects - Stack Overflow

PHOTO EMBED

Mon Mar 29 2021 15:21:29 GMT+0000 (UTC)

Saved by @praj #javascript

Object.filter = function( obj, predicate) {
    let result = {}, key;

    for (key in obj) {
        if (obj.hasOwnProperty(key) && !predicate(obj[key])) {
            result[key] = obj[key];
        }
    }

    return result;
};
content_copyCOPY

filter() for Objects

https://stackoverflow.com/questions/5072136/javascript-filter-for-objects/37616104