Level 65 Level 67
Level 66

[Quiz] Arrays

52 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

What is an Array?
An array is a special variable, which can hold more than one value, at a time.what if you had not 3 cars, but 300? The best solution here is to use an array! An a…
What is a element?
An element is a value in an array.
What is an index?
The ordered position of the elements in the array.
Are arrays typed or untyped?
JS arrays are untyped, meaning any type of data can be inserted as a value.
What does it mean that JS arrays are dynamic?
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?
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?
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.
var empty = [];
What is the construct for an array literal?
var a = new array();
What is an array constructor? How could you add to array constructors?
In the construct var a = new array(45); what does the 45 stand for?
The number of indexes the array should create. Additional arguments would specify the values of the array.
Are all indexes property names?
Yes, but not all property names are indexes. Only numbers between 0 - 2^32-2.
It returns undefined because it is a type of object property
What happens when you call an array index that does not exist?
How can you make a value of an array spare?
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.
The values of index numbers larger than the new length of the array will be deleted.
What happens if you set a new length to an array that is smaller than the current length of it?
What is the value of the length property?
i + 1 because the first index number = 0.
array.push(); ---> adds one or more elements to the end of the array
Other than assigning values to new indexes, how can elements of an array be created?
That index becomes sparse.
What happens if you delete a value from an array index?
if (!a[i]) continue;
What code in a for loop would skip null, undefined, or nonexistent elements?
if (a[i] === undefined) continue;
What code in a for loop would skip undefined, or nonexistent elements?
(!(i in a)) continue;
What code in a for loop would skip nonexistent elements?
if (!a.hasOwnProperty(i)) continue;
How would you test for any inherited properties an array would have from its prototype and filter them out?
What is a heterogeneous array?
An array that is comprised of different types of values: strings, numbers, and booleans
What is a jagged array?
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?
An array that has one or more arrays nested inside of it
Define array.join()
A method that converts all elements of an array to a string and concatenates them returning the resulting string
reverses the order of elements in an array and returns the reversed array.
sorts elements of an array in place and returns the sorted array. When sort() is called with no arguments, it returns indexes in alphabetical order. Undefined elements sort to the back of the array.
How do you sort an array by a means other than alphabetical?
You must pass a comparison function . This argument defines which of two arguments should appear first.
creates and returns a new array that contains the elements of the original array on which concat was invoked, followed by each of the arguments.
returns a slice of a specific subarray. Its first argument specifies the beginning, the second the end. If no end is specified, it returns all elements from the specified start to the end of…
general purpose method for inserting or removing elements from an array. It modifies the array on which it is invoked. First two arguments specify which values should be deleted, and any additional arguments specify values to be added.
deletes the last element of an array
deletes the first element of an array
What Date object method is used to return a string containing the date and time?
iterates through an array and invokes a function you specify for each element
You must throw an exception and place the call to forEach() within a try block.
If you need to terminate the loop early when using .forEach() method, how does it work?
The map() method passes each element of the array on which it is invoked to the function you specify, and returns an array containing the value by that function
the array.filter() returns an array containing a subset of the elements of the array on which it was invoked. The function must be able to return a true or false on each element. I…
every() method apply a predicate function you specify to the elements of the array, and then return true and false. It will only return true if the predicate is true for ALL elements of the array.
some(); method will return true if there exists at least one element in the array for which the predicate returns true.
the reduce() method combines the elements of an array using the function you specify to produce a single value. The first part performs the reduction operation and the optional second argument tells the function…
How is reduceRight() different from array.reduce()?
It begins at the array from the highest index and works backwards.
indexOf() and lastIndexOf()
indexOf() method searches an array for an element with a specified value and returns the index of the first such element found, or -1 if it can't be found. lastIndexOf() returns the last index that meets that criteria.
returns true or false depending on if an object is an array or not
var cat = {name: "Chunkie", Age: 18}
How could you add an object to an array?
var languages = ["HTML", "CSS", "JavaScript", "Python", "Ruby"];
How do you access an array by an offset?
What does the Array.join() method do?
Joins all elements of an array into a string.
string = array.join(separator)
What's the syntax of the Array.join() method?
What parameters does Array.join() accept?
separator: Specifies a string to separate each element of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma.
What does the Array.length() method do?
Returns an unsigned, 32-bit integer that specifies the number of elements in an array. The value of the length property is an integer with a positive sign and a value less than 2 to the 32 power (232).
Besides iterating, what can Array.length be used for?
We can set the length property to truncate an array at any time.
Can you expand an array with Array.length()?
No, When you extend an array by changing its length property, the number of actual elements does not increase; for example, if you set length to 3 when it is currently 2, the array still contains only 2 elements.