TypeScript · Junior · Question 64 of 75

Why can [1, 2].forEach((n) => console.log(n)) pass a callback with one parameter when forEach passes three?

Explanation

This mirrors common JavaScript practice. The opposite (a callback requiring more parameters than provided) is an error.

Further reading

Problem with a question

TypeScript · Junior · question 64

Test yourself

Take the TypeScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz