MCPcopy Create free account
hub / github.com/apache/struts-examples / forEach

Function forEach

rest-angular/src/main/webapp/js/lib/angular/angular.js:306–348  ·  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

304 */
305
306function forEach(obj, iterator, context) {
307 var key, length;
308 if (obj) {
309 if (isFunction(obj)) {
310 for (key in obj) {
311 // Need to check if hasOwnProperty exists,
312 // as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function
313 if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) {
314 iterator.call(context, obj[key], key, obj);
315 }
316 }
317 } else if (isArray(obj) || isArrayLike(obj)) {
318 var isPrimitive = typeof obj !== 'object';
319 for (key = 0, length = obj.length; key < length; key++) {
320 if (isPrimitive || key in obj) {
321 iterator.call(context, obj[key], key, obj);
322 }
323 }
324 } else if (obj.forEach && obj.forEach !== forEach) {
325 obj.forEach(iterator, context, obj);
326 } else if (isBlankObject(obj)) {
327 // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty
328 for (key in obj) {
329 iterator.call(context, obj[key], key, obj);
330 }
331 } else if (typeof obj.hasOwnProperty === 'function') {
332 // Slow path for objects inheriting Object.prototype, hasOwnProperty check needed
333 for (key in obj) {
334 if (obj.hasOwnProperty(key)) {
335 iterator.call(context, obj[key], key, obj);
336 }
337 }
338 } else {
339 // Slow path for objects which do not have a method `hasOwnProperty`
340 for (key in obj) {
341 if (hasOwnProperty.call(obj, key)) {
342 iterator.call(context, obj[key], key, obj);
343 }
344 }
345 }
346 }
347 return obj;
348}
349
350function forEachSorted(obj, iterator, context) {
351 var keys = 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 3

isFunctionFunction · 0.70
isArrayLikeFunction · 0.70
isBlankObjectFunction · 0.70

Tested by

no test coverage detected