Iterate over JavaScript object with index

This is just meant to be an addition to jonas w’s solutions. If you need the key of the current value: const object = {a:2, b:4, c:6, d:8}; for (const [index, [key, value]] of Object.entries(Object.entries(object))) { console.log(`${index}: ${key} = ${value}`); } Object.entries(object).forEach(([key, value], index) => { console.log(`${index}: ${key} = ${value}`); }); Of course, you can … Read more

Fix warning “C-style for Statement is deprecated” in Swift 3

C-style for loop has been deprecated in Swift 3. You can continue using it for a while, but they will certainly disappear in the future. You can rewrite your loop to Swift’s style: for i in 0..<len { let length = UInt32 (letters.length) let rand = arc4random_uniform(length) randomString.appendFormat(“%C”, letters.characterAtIndex(Int(rand))) } Since you don’t use i … Read more

Is it possible to do a For…Each Loop Backwards?

I think the documentation referenced in Mike’s answer below is extremely misleading. The order of For Each is defined by the collection it’s called (i.e. its implementation of IEnumerable/IEnumerable<T>), but that’s not the same as saying it shouldn’t be used when the order is important. Many collections (such as arrays, List<T> etc) always go in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)