Beginner JavaScript
Q24 / 100

What is the difference between for...of and for...in?

Correct! Well done.

Incorrect.

The correct answer is B) for...of iterates values of iterables; for...in iterates enumerable property keys of objects

B

Correct Answer

for...of iterates values of iterables; for...in iterates enumerable property keys of objects

Explanation

for (const v of [1,2,3]) gives values 1,2,3. for (const k in {a:1}) gives key "a". Avoid for...in on arrays due to inherited properties.

Progress
24/100