Questenaتدريب يوضح لك ما ينبغي مراجعته لاحقًا
السؤال 91

Given const list = [1], what happens when list.push(2) is called?

  1. A TypeError occurs because every const value is deeply immutable
  2. The call is ignored and list remains [1]
  3. The call succeeds and list becomes [1, 2]الإجابة الصحيحة
  4. A new binding named list is created

الشرح

The const restriction prevents assigning a different value to the list binding, but push changes the existing Array object. The call is therefore allowed and the array becomes [1, 2]; const does not recursively freeze held objects.

تابع هذا الاختبار

بدء التدريب
السؤال 91: Given const list = [1], what happens when list.push(2) is… · JavaScript Fundamentals · Questena