Skip to content
JavaScript·Beginner·Conceptual·1 min read

Why can for...in be dangerous for record iteration?

Short interview answer

It enumerates enumerable string properties from both the object and its prototypes. Object.keys or Object.entries better expresses own-property record iteration.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Prototype chain

Related questions