Top "Foreach" questions

foreach is a looping construct that executes a given piece of code for each element in a list/collection/array.

How to loop through all the elements returned from getElementsByTagName

I am trying to loop through all the elements retruned from getElementsByTagName("input") using forEach. Any ideas why this does …

javascript arrays foreach getelementsbytagname
What is the correct way of using C++11's range-based for?

What is the correct way of using C++11's range-based for? What syntax should be used? for (auto elem : container), …

c++ c++11 foreach
How to use promise in forEach loop of array to populate an object

I am running a forEach loop on an array and making two calls which return promises, and I want to …

javascript arrays foreach promise es6-promise
php foreach continue

I am trying to skip to the next iteration of the loop if certain conditions are not met. The problem …

php foreach continue
stdClass object and foreach loops

I am using the following code to get data from a website using Soap. $client = new SoapClient('http://some.url.…

php object foreach stdclass
JSTL continue, break inside foreach

I want to insert "continue" inside foreach in JSTL. Please let me know if there is a way to achieve …

jsp foreach jstl
How to break ForEach Loop in TypeScript

I have a the below code, on which i am unable to break the loop on certain conditions. isVoteTally(): boolean { …

angular typescript foreach break
Last iteration of enhanced for loop in java

Is there a way to determine if the loop is iterating for the last time. My code looks something like …

java for-loop foreach conditional-execution
Performance of foreach, array_map with lambda and array_map with static function

What's the performance difference (if there is any) between these three approaches, both used to transform an array to another …

php performance foreach lambda array-map
What does [].forEach.call() do in JavaScript?

I was looking at some snippets of code, and I found multiple elements calling a function over a node list …

javascript arrays foreach ecmascript-5 nodelist