Q 1: Name two ways to dynamically add the value “bar” to the array “foo”
foo.push("bar") foo[foo.length] = "bar";
A: The “length” property
Q 4: If the array “foo” has a length of 10, what is the index of the first element in the array?
Q 5: If the array “foo” has a length of 10, what is the index of the last element in the array?
Q 6: What is the syntax you would use to assign the first element in the array “foo” to the variable “bar”?
var bar = foo;
Q 8: Given the following line of code, what is the length of the array “foo”?
var foo = ;
Hint: foo is an Array literal, but in this line of code, no elements have been defined.
Q 9: What does the array.shift() method do, and what does it return?
A: It removes the first element from the array and returns that element
Q 10: Given the following line of code, what would be the output of the console?
var foo = new Array(3); console.log(foo);
A: [undefined, undefined, undefined]
Mozilla Developer Network