Top "For-in-loop" questions

'for-in' is a type of 'Fast enumeration', which is a language feature that allows you to efficiently and safely enumerate over the contents of a collection using a concise syntax.

How to dynamically populate an array using a for in loop

To return an array set with a sequence of random numbers between 1 and 500 I tried to refactor a standard for …

javascript arrays for-in-loop
Javascript Array Splice Not working fine

var cache = []; cache[0] = "0"; cache[1] = "1"; cache[2] = "2"; cache[3] = "3"; cache[4] = "4"; cache["r"] = "r"; console.log(cache.length); for(key in cache){ if(isNaN(…

javascript jquery arrays splice for-in-loop
Swift: How to use for-in loop with an optional?

What's the proper way to use for-in loop with an optional? Right now I always perform an optional binding before …

swift2 optional for-in-loop
Uncaught TypeError: items is not iterable

My understanding is that for...in loops are designed to iterate over objects in Javascript. See this post and this …

javascript object for-loop for-in-loop
How to do for in TObjectList?

I am trying to use for in to iterate a TObjectList: program Project1; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, …

delphi for-loop iterator for-in-loop listiterator
When to use forEach(_:) instead of for in?

As documented in both Array and Dictionary forEach(_:) Instance methods: Calls the given closure on each element in the sequence …

swift loops foreach sequence for-in-loop
for..in or for..of Object keys

So my IDE doesn't like when I use a for..in loop to iterate over an object keys. I get …

javascript object for-loop for-in-loop for-of-loop
Counter as variable in for-in-loops

When normally using a for-in-loop, the counter (in this case number) is a constant in each iteration: for number in 1...10 { // …

variables swift constants declaration for-in-loop
JavaScript Loops: for...in vs for

I faced a strange behaviour in Javascript. I get "Object doesn't support this property or method" exception for the removeAttribute …

javascript arrays for-loop for-in-loop
JS function being called twice?

I can't seem to find the bug that's making the code run twice, and JSFiddle isn't working for me so …

javascript function loops for-in-loop