我有喜歡的數組:選號鍵包含在Javascript
var arr = ["hello","world"]
// This array can contain any number of strings
對象是這樣的:
var obj_arr = {
"abc-hello-1": 20,
"def-world-2": 30,
"lmn-lo-3": 4
}
我想有這隻有那些包含對象鍵,它包含上面的數組值作爲子字符串。 對於如:
結果會是這樣的:
var result = {
"abc-hello-1": 20,
"def-world-2": 30,
}
我想要做這樣的事情(使用lodash):
var to_be_ensembled = _.pickBy(timestampObj, function(value, key) {
return _.includes(key, "hello");
// here instead of "hello" array should be there
});
感謝。任何奇特的方式使用lodash? – Ashag