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

parent.active is true, and child was created with parent as its prototype. What does "active" in child evaluate to?

  1. undefined, because inherited properties have no boolean result
  2. false, because only child's own properties are searched
  3. true, because the inherited property is foundՃիշտ պատասխան
  4. A TypeError, because in cannot inspect prototypes

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

The in operator searches both the object and its prototype chain, so the inherited active property makes the test true. Saying false because child lacks an own property mistakes this operator for an ownership-only check.

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

Սկսել վարժանքը
Հարց 67: parent.active is true, and child was created with parent as… · JavaScript Fundamentals · Questena