« Lodash » : différence entre les versions
Apparence
Aucun résumé des modifications |
Aucun résumé des modifications |
||
Ligne 2 : | Ligne 2 : | ||
= Links = | = Links = | ||
* [https://lodash.com/docs Documentation] | * [https://lodash.com/docs Documentation] | ||
= [https://lodash.com/docs/4.17.15#includes includes] = | |||
Checks if value is in collection. | |||
<kode lang='js'> | |||
_.includes('abcd', 'bc'); | |||
// => true | |||
</kode> | |||
= [https://lodash.com/docs/4.17.15#forOwn forOwn] = | = [https://lodash.com/docs/4.17.15#forOwn forOwn] = |
Version du 28 janvier 2021 à 17:03
Links
includes
Checks if value is in collection.
_.includes('abcd', 'bc');
// => true
|
forOwn
Iterates over own enumerable string keyed properties of an object.
let json = {
"A": "1",
"B": "2",
"C": {
"C1": "3",
"C2": "4"
},
"D": [ "5", "6" ]
};
_.forOwn(json, (value, key) => {
console.log(`key: ${key} - value: ${value}`);
});
// key: A - value: 1
// key: B - value: 2
// key: C - value: [object Object]
// key: D - value: 5,6
|