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

Which statement correctly contrasts shift and unshift?

  1. Both remove the first element
  2. shift returns the removed first element; unshift returns the new lengthՃիշտ պատասխան
  3. shift adds at the beginning; unshift removes from it
  4. Neither method changes the array

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

shift removes and returns the first element, whereas unshift adds at the beginning and returns the new length. Saying both return an element overlooks that insertion methods report length instead.

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

Սկսել վարժանքը
Հարց 43: Which statement correctly contrasts shift and unshift? · JavaScript Fundamentals · Questena