QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 107

An ordinary object created with new Object is used directly on the right side of for...of. No iterator was added. What happens?

  1. Its own values are visited automatically
  2. Its own property names are visited automatically
  3. A TypeError is thrown because the object is not iterableՃիշտ պատասխան
  4. The loop runs zero times without reporting a problem

Բացատրություն

An ordinary object does not provide the iterable protocol by default, so for...of cannot consume it and throws a TypeError. Having enumerable properties is insufficient; arrays returned by Object.keys or related methods would be iterable instead.

Շարունակեք այս թեստով

Սկսել վարժանքը
Հարց 107: An ordinary object created with new Object is used directly… · JavaScript Fundamentals · Questena