Every line of 'foreach javascript object' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
276 export function objectForEach( 277 obj: { [key: string]: V }, 278 cb: (value: V, key: string) => void 279 ): void { 280 Object.keys(obj).forEach(key => cb(obj[key], key)); 281 }
25 function forEach(object, callback, context) { 26 var index, length; 27 if (object.length) { 28 if (Array.prototype.forEach) { 29 Array.prototype.forEach.call(object, callback, context); 30 } else { 31 for (index = 0, length = object.length; index < length; index += 1) { 32 callback.call(context || this, object[index], index, object); 33 } 34 } 35 } else { 36 for (index in object) { 37 if (object.hasOwnProperty(index)) { 38 callback.call(context || this, object[index], index, object); 39 } 40 } 41 } 42 }
4 export function forEach(obj, callback) { 5 if (obj) { 6 Object.keys(obj).forEach((key) => { 7 // eslint-disable-line no-restricted-syntax 8 if ({}.hasOwnProperty.call(obj, key)) { 9 callback(key, obj[key]); 10 } 11 }); 12 } 13 }
1026 export function foreach(obj: { [key: string]: V }, action: (key: string, value: V) => void) { 1027 1028 for (const name in obj) { 1029 if (obj.hasOwnProperty == null || obj.hasOwnProperty(name)) { 1030 action(name, obj[name]); 1031 } 1032 } 1033 }