MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / forEach

Function forEach

code/songhop/www/lib/angular/angular.js:307–336  ·  view source on GitHub ↗

* @ngdoc function * @name angular.forEach * @module ng * @kind function * * @description * Invokes the `iterator` function once for each item in `obj` collection, which can be either an * object or an array. The `iterator` function is invoked with `iterator(value, key, obj)`, where `value` *

(obj, iterator, context)

Source from the content-addressed store, hash-verified

305 */
306
307function forEach(obj, iterator, context) {
308 var key, length;
309 if (obj) {
310 if (isFunction(obj)) {
311 for (key in obj) {
312 // Need to check if hasOwnProperty exists,
313 // as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function
314 if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) {
315 iterator.call(context, obj[key], key, obj);
316 }
317 }
318 } else if (isArray(obj) || isArrayLike(obj)) {
319 var isPrimitive = typeof obj !== 'object';
320 for (key = 0, length = obj.length; key < length; key++) {
321 if (isPrimitive || key in obj) {
322 iterator.call(context, obj[key], key, obj);
323 }
324 }
325 } else if (obj.forEach && obj.forEach !== forEach) {
326 obj.forEach(iterator, context, obj);
327 } else {
328 for (key in obj) {
329 if (obj.hasOwnProperty(key)) {
330 iterator.call(context, obj[key], key, obj);
331 }
332 }
333 }
334 }
335 return obj;
336}
337
338function sortedKeys(obj) {
339 return Object.keys(obj).sort();

Callers 15

copyFunction · 0.70
parseKeyValueFunction · 0.70
toKeyValueFunction · 0.70
angularInitFunction · 0.70
bootstrapFunction · 0.70
jqLiteBuildFragmentFunction · 0.70
jqLiteOffFunction · 0.70
jqLiteRemoveClassFunction · 0.70
jqLiteAddClassFunction · 0.70
angular.jsFile · 0.70
HashMapFunction · 0.70
annotateFunction · 0.70

Calls 2

isFunctionFunction · 0.70
isArrayLikeFunction · 0.70

Tested by

no test coverage detected