Filter by Key

PHOTO EMBED

Mon Dec 06 2021 04:38:36 GMT+0000 (UTC)

Saved by @GodFather #javascript

//optional array to object
var object = Object.assign({}, data);


var object = ['apel', 'mangga', 'jeruk']

const allowed = ['mangga'];

var filtered = Object.keys(object)
.filter(key => allowed.includes(key))
.reduce((obj, key) => {
    obj[key] = object[key];
    return obj;
}, {});
data = filtered;
content_copyCOPY