JavaScript Arrays Properties and Methods

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the index of the first element in an array?

  • 1
  • 0 (correct)
  • -1
  • None of the above

What is the purpose of the Array object when declaring an array?

  • To create an array with a specific data type
  • To initialize an empty array
  • To create a multidimensional array
  • To specify the length of the array (correct)

What is the difference between var a_ary = ['a', 'b', 'c']; and var a_ary = new Array('a', 'b', 'c');?

  • The first one creates an array, the second one creates a string
  • The first one creates a string, the second one creates an array
  • There is no difference, both create an array (correct)
  • The first one creates a sparse array, the second one creates a dense array

What is the output of console.log(a_ary.length);?

<p>8 (A)</p> Signup and view all the answers

What is the purpose of the length property of an array?

<p>To get the number of elements in the array (B)</p> Signup and view all the answers

What happens when you use Array.prototype.unshift() on an array?

<p>It adds elements to the beginning of the array (C)</p> Signup and view all the answers

What is the difference between Array.prototype.shift() and Array.prototype.pop()?

<p>shift() removes the first element, pop() removes the last element (A)</p> Signup and view all the answers

What is the purpose of the Array.prototype.splice() method?

<p>To add or remove elements from an array at a specified position (D)</p> Signup and view all the answers

What is the return value of the Array.prototype.shift() method?

<p>The removed element (D)</p> Signup and view all the answers

What happens when you use Array.prototype.push() on an array?

<p>It adds elements to the end of the array (A)</p> Signup and view all the answers

Flashcards are hidden until you start studying

More Like This

JavaScript Arrays
28 questions
JavaScript Arrays
3 questions

JavaScript Arrays

LoyalIllumination avatar
LoyalIllumination
JavaScript Arrays and Callbacks
22 questions

JavaScript Arrays and Callbacks

CheeryComprehension5871 avatar
CheeryComprehension5871
Use Quizgecko on...
Browser
Browser