• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 5 pages
Exam (elaborations)

Javascript Array Exam Questions And Answers

Document preview thumbnail
Preview 2 out of 5 pages

JAVASCRIPT ARRAY EXAM QUESTIONS AND ANSWERS

Content preview

JAVASCRIPT ARRAY EXAM QUESTIONS
AND ANSWERS

What happens when you call an array index that does not exist? - Answer-It returns
undefined because it is a type of object property

How can you make a value of an array spare? - Answer-Use the delete operator to
delete a pre-existing value or specify a value at an index using a[995] = 100; So the
value of index number 995 of a array is now 100.

What happens if you set a new length to an array that is smaller than the current length
of it? - Answer-The values of index numbers larger than the new length of the array will
be deleted.

What is the value of the length property? - Answer-i + 1 because the first index number
= 0.

What is an array? - Answer-An array is an ordered collection of values.

What is a element? - Answer-An element is a value in an array.

What is an index? - Answer-The ordered position of the elements in the array.

Are arrays typed or untyped? - Answer-JS arrays are untyped, meaning any type of
data can be inserted as a value.

What does it mean that JS arrays are dynamic? - Answer-It means they grow and shrink
as needed; there is no need to declare a fixed size.

What does it mean that JS arrays are sparse? - Answer-It means that the elements do
not have contiguous indexes from zero, but that there may be gaps.

What is the length property for sparse or nonsparse arrays? How does the index
number related to the length? - Answer-For non-sparse arrays, the length equals the
number of elements in the array. For sparse arrays, the length is larger than the index of
the elements because of empty indexes.

What is the construct for an array literal? - Answer-var empty = [];
An empty array.

, What is an array constructor? How could you add to array constructors? - Answer-var a
= new array();
Constructor array with no arguments.

var family = new Array();
family[0] = new Person("alice", 40);
family[1] = new Person("bob", 42);

In the construct var a = new array(45); what does the 45 stand for? - Answer-The
number of indexes the array should create. Additional arguments would specify the
values of the array.

Are all indexes property names? - Answer-Yes, but not all property names are indexes.
Only numbers between 0 - 2^32-2.

Other than assigning values to new indexes, how can elements of an array be created?
- Answer-array.push(); ---> adds one or more elements to the end of the array
array.unshift() ---> pushes an array value to the beginning of an array and shifting all
other values to a larger index

What happens if you delete a value from an array index? - Answer-That index becomes
sparse.

What code in a for loop would skip null, undefined, or nonexistent elements? - Answer-if
(!a[i]) continue;

What code in a for loop would skip undefined, or nonexistent elements? - Answer-if (a[i]
=== undefined) continue;

What code in a for loop would skip nonexistent elements? - Answer-(!(i in a)) continue;

How would you test for any inherited properties an array would have from its prototype
and filter them out? - Answer-if (!a.hasOwnProperty(i)) continue;
Which skips inherited properties

What is a heterogeneous array? - Answer-An array that is comprised of different types
of values: strings, numbers, and booleans

What is a jagged array? - Answer-An array that is composed of two or more arrays that
do not have the same number of values in their respective arrays

What is a multidimensional array? - Answer-An array that has one or more arrays
nested inside of it

Define array.join() - Answer-A method that converts all elements of an array to a string
and concatenates them returning the resulting string

Document information

Uploaded on
July 14, 2025
Number of pages
5
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$13.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Scholarsstudyguide
3.8
(169)
Sold
853
Followers
476
Items
16410
Last sold
1 week ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions