Tagged articles
3 articles
Page 1 of 1
JavaScript
JavaScript
Apr 24, 2025 · Frontend Development

Why for...in Loops Can Break Your JavaScript Arrays and Safer Alternatives

The article explains that JavaScript’s for...in loop, intended for object property enumeration, can produce unordered results, traverse custom and prototype properties, and cause performance and bug issues when used on arrays, and it recommends safer alternatives such as classic for loops, for…of, forEach, and functional methods.

JavaScriptarray iterationbest practices
0 likes · 4 min read
Why for...in Loops Can Break Your JavaScript Arrays and Safer Alternatives
WeDoctor Frontend Technology
WeDoctor Frontend Technology
Jul 21, 2021 · Frontend Development

7 JavaScript Object Traversal Techniques Illustrated with Allen Iverson

This article examines seven ways to iterate over JavaScript objects—excluding arrays, Map, and Set—using a sample player object modeled after Allen Iverson, detailing each method’s handling of own, inherited, enumerable, non‑enumerable, and Symbol properties, with code examples and output analysis.

Object TraversalObject.keysSymbol
0 likes · 9 min read
7 JavaScript Object Traversal Techniques Illustrated with Allen Iverson
Vipshop Quality Engineering
Vipshop Quality Engineering
Aug 8, 2017 · Frontend Development

Why for…in Breaks JavaScript Arrays and How for…of Fixes It

This article examines a production incident caused by using the ES5 for...in loop to iterate over arrays, explains its pitfalls such as prototype pollution and string indexes, and demonstrates why switching to the ES6 for...of construct provides safer, more predictable array traversal.

JavaScriptarray iterationes6
0 likes · 6 min read
Why for…in Breaks JavaScript Arrays and How for…of Fixes It