Test 2 Flashcards
A(n) ______ is a type of object used for storing multiple values in a single variable.
a. array
b. data structure
c. multi-layer variable
d. all of the above
a. array
- Arrays may contain data of any data type. T F
True
Arrays may contain strings, Boolean values, functions and objects but they
cannot contain other arrays. T F
False
The syntax for creating an array and assigning it to a variable value is:
a. var myArray = Array;
b. var myArray = new Array;
c. var myArray = Array( );
d. var myArray = new Array( );
d. var myArray = new Array( );
The shorthand syntax for creating an array and assigning it to a variable value is: a. var myArray = ( ) ;
b. var myArray = new ( );
c. var myArray = new [ ];
d. var myArray = [ ];
d. var myArray = [ ];
Arrays can be assigned values at the time they are created or they can be added
after the array has been created. T F
True
Arrays contain indexes that begin with zero. T F
True
All arrays have a ______ property that tells how many items the array contains.
a. count
b. length
c. size
d. maxIndex
b. length
The total number of items in an array is always one higher than the highest
index number. T F
True
To add or delete specific items from an array, the best method to use is ______.
a. concat( )
b. join( )
c. splice( )
d. slice( )
c. splice( )
Which of the following is NOT true when applying the spread operator:
a. it allows you to combine two arrays by positioning one array at a specific point in the other
b. it can be applied as a placeholder for additional data to be added at a
later time
c. it can be used to divide an array into a list of arguments to pass to a function
d. it can be used to collect and allocate values into an array
b. it can be applied as a placeholder for additional data to be added at a
later time
Both the forEach( ) and the map( ) methods can be used to iterate through arrays. T F
True
The difference between the forEach( ) and the map( ) methods is that forEach( ) can return a value whereas the map( ) cannot. T F
False
Which statement is true when using the sort( ) method on an array:
a. sorting reassigns the sorted data into a new index based on its sorted value
b. sorting only works as long as each index contains the same data type
c. numbers are sorted alphabetically – meaning by the first digit
d. all of the above are correct
c. numbers are sorted alphabetically – meaning by the first digit
It is usually more efficient and easier to maintain your code if you assign your event handlers inline rather than assigning them directly to the object properties. T F
False
Mouse events, keyboard events, DOM object events and form events are the most common types of web page events but there are others too. T F
True
Not all event handles can work with (be applied to) every HTML tag. T F
True
Which of the following would NOT be appropriate to apply to a web page button:
a. onkeydown
b. onfocus
c. ondblclick
d. onload
d. onload
Which of the following is NOT true when using the addEventListener( ):
a. it requires two parameters: first, the name of the function being called; and second, the type of event being assigned
b. should be used when you wish to apply more than one event to an object
c. it can listen on any DOM node you specify (not just page elements)
d. it can be used to add multiple events to the same object so that they will both execute when the event is triggered
a. it requires two parameters: first, the name of the function being called; and second, the type of event being assigned
Which function would remove an event listener that has been previously applied:
a. deleteEventListener( )
b. cancelEventListener( )
c. removeEventListener( )
d. scrubEventListener( )
c. removeEventListener( )
During bubbling, nested elements fire events:
a. at the same time
b. from the innermost to the outermost
c. from the outermost to the innermost
d. based on the type of node they are assigned to
b. from the innermost to the outermost
To turn on capture mode instead of bubbling, what is the third parameter that needs to be added to the addEventListener( ) function?
a. capture
b. cancel
c. true
d. false
c. true
Which of the following is NOT true about the event object:
a. all objects in the DOM are based on it
b. it can be used to obtain more detailed information about an event that has been detected
c. the event object is automatically passed to event handlers when called
d. in referring to an event in your code, it must be named either “event” or designated by the letter “ e “ only
d. in referring to an event in your code, it must be named either “event” or designated by the letter “ e “ only
To prevent an event from doing what it would normally do, the _____________ method can be used.
a. perventDefault( )
b. cancelDefault( )
c. preventEvent( )
d. cancelEvent( )
a. perventDefault( )