Test 2 Flashcards

1
Q

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

a. array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. Arrays may contain data of any data type. T F
A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Arrays may contain strings, Boolean values, functions and objects but they
cannot contain other arrays. T F

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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( );

A

d. var myArray = new Array( );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
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 = [ ];

A

d. var myArray = [ ];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Arrays can be assigned values at the time they are created or they can be added
after the array has been created. T F

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Arrays contain indexes that begin with zero. T F

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

All arrays have a ______ property that tells how many items the array contains.
a. count

b. length
c. size
d. maxIndex

A

b. length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The total number of items in an array is always one higher than the highest
index number. T F

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

To add or delete specific items from an array, the best method to use is ______.
a. concat( )

b. join( )
c. splice( )
d. slice( )

A

c. splice( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

b. it can be applied as a placeholder for additional data to be added at a
later time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Both the forEach( ) and the map( ) methods can be used to iterate through arrays. T F

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The difference between the forEach( ) and the map( ) methods is that forEach( ) can return a value whereas the map( ) cannot. T F

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

c. numbers are sorted alphabetically – meaning by the first digit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

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

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Not all event handles can work with (be applied to) every HTML tag. T F

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Which of the following would NOT be appropriate to apply to a web page button:

a. onkeydown
b. onfocus
c. ondblclick
d. onload

A

d. onload

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

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

a. it requires two parameters: first, the name of the function being called; and second, the type of event being assigned

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Which function would remove an event listener that has been previously applied:

a. deleteEventListener( )
b. cancelEventListener( )
c. removeEventListener( )
d. scrubEventListener( )

A

c. removeEventListener( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

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

A

b. from the innermost to the outermost

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

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

A

c. true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

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

A

d. in referring to an event in your code, it must be named either “event” or designated by the letter “ e “ only

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

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

a. perventDefault( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Which of the following is not a JavaScript operator? a. = b. == c. && d. =!
d. =!
26
The general form of an “ if “ statement is: a. if (this condition is true) then do this b. if (this condition is false) then do this c. if (this condition is zero) then do this d. both A and B are correct, depending on the condition used
a. if (this condition is true) then do this
27
What does an assignment operator do? a. assigns a new value to a variable b. gives a variable a new name c. performs a comparison d. all of the above, depending on how it is used
a. assigns a new value to a variable
28
What does a comparison operator do? a. compares only strings; it does not work on numbers or calculations b. compares two values or statements, and returns a numerical value c. compares two values or statements, and returns a value of true or false d. compares only numbers; it does not work on strings
c. compares two values or statements, and returns a value of true or false
29
Which of the following comparisons will return true? a. 4 != 3 b. 4 == 3 c. 4 < 3 d. 4 <= 3
a. 4 != 3
30
Which of the following comparisons will return false? a. 4 != 3 b. 3 == 3 c. 4 > 3 d. 4 <= 3
d. 4 <= 3
31
The ________ operators allow you to compare two conditional statements to see if one or both of the statements are true and to proceed accordingly. a. conditional b. assignment c. logical d. evaluation
c.logical
32
Which of the following statements will return true? a. (3 == 3) && (5 < 1) b. !(17 >= 20) c. (3 != 3) || (7 < 2) d. (1 == 1) && (2 < 0)
b. !(17 >= 20)
33
Which of the following statements will return false? a. !(3 <= 1) b. (4 >= 4) && (5 <= 2) c. (“a” == “a”) && (“c” != “d”) d. (2 < 3) || (3 < 2)
b.(4 >= 4) && (5 <= 2)
34
Which of the following will compare both value and type: a. = b. = = c. = = = d. both B and C are correct
c. = = =
35
If we want code to execute if a condition is not true, we use the ____ construct. a. if…else b. if…then c. do…while d. switch
a. if…else
36
Which of the following is likely to cause an infinite loop to occur: a. the loop counter is never incremented/decremented inside the loop b. the loop contains too many conditional statements to be evaluated c. the loop does not contain a break statement to be executed when a pre- arranged condition is met d. yo’ mamma helped you write the code for your loop
a. the loop counter is never incremented/decremented inside the loop
37
All switch statements must include a default option. T F
False
38
All case statements inside a switch must include a break statement. T F
True
39
The ________ loop is very similar to the if statement syntax except that after executing the code (as long as the condition evaluates true), it goes back and tests the condition again and again until it becomes false. a. while b. for c. do…while d. both A and C are correct
a. while
40
The statements in a ______ loop will always execute at least once even if the conditional statement is never met. a. while b. for c. do…while d. both A and C are correct
c. do…while
41
With the ______ loop, we can specify an initial condition, a test condition (to end the loop), and a means of changing the counter variable for each pass through the loop all in one statement. a. while b. for c. do…while d. for…in
b. for
42
The _______ loop is a special type of loop that is used exclusively for stepping through the properties of an object so a loop counter or creating a conditional test to end the loop is not necessary. a. for…in b. for c. while…in d. do while…in
a. for…in
43
To set up a specific delay in the execution of your JavaScript code, you can deploy either of which two methods that will function as a timer for your code? a. timeout( ) ; interval( ) b. SetTimeout( ) ; SetInterval( ) c. Timeout( ) ; Interval( ) d. setTimeout( ) ; setInterval( )
d. setTimeout( ) ; setInterval( )
44
The break command works within a loop pretty much the same as it does in a switch statement – it kicks you out of the loop and returns operation to the line of code immediately after the closing curly brace. T F
True
45
Procedural programming is characterized by having data stored in variables. T F
True
46
A(n) ______ of an object is a particular application of an object “template” to create a working object based on specific data. a. copy b. class c. prototype d. instance
d. instance
47
Which of the following is NOT an advantage of utilizing object-oriented programming: a. your code can be re-used in a variety of scripts. b. you can define the way objects interact with other parts of your scripts by controlling the methods and properties the rest of the program can “see”. c. new objects can be created based on the designs of previously-created objects. d. you can create your own HTML and CSS code definitions that can be used only in your web pages for unique functionality and appearance.
d. you can create your own HTML and CSS code definitions that can be used only in your web pages for unique functionality and appearance.
48
Creating new objects by using the design of currently-existing objects is called: a. encapsulation b. inheritance c. instantiation d. prototyping
b. inheritance
49
Which of the following is a valid method for creating a direct instance of an object: a. myObject = new Object( ); b. myObject.create( ); c. myObject = new Object; d. myObject.new( );
a. myObject = new Object( );
50
New JavaScript objects are automatically created with a default set of properties or methods. T F
False
51
Which of the following correctly creates a new function and then assigns that newly-created method to your new object called firstObject: a."" function firstFunct( ) { alert (“Hello World!”); } firstObject.displayGreeting = firstFunct( )"" b."" function firstFunct( ) { alert (“Hello World!”); firstObject.displayGreeting = firstFunct }"" c. ""function firstFunct( ) { alert (“Hello World!”); } firstObject.displayGreeting = firstFunct"" d."" function firstFunct( ) { alert (“Hello World!”); } firstObject.firstFunct = displayGreeting ""
C. ""function firstFunct( ) { alert (“Hello World!”); } firstObject.displayGreeting = firstFunct""
52
Which of the following will allow you to call the object’s method that you assigned in question #7: a. firstObject.displayGreeting; b. firstObject.displayGreeting( ); c. firstObject = displayGreeting( ); d. firstObject = displayGreeting;
b. firstObject.displayGreeting( );
53
After directly creating an instance of a new object, if you need to create another instance of that same object, you must go through the same process again – creating the object, adding the properties, etc. T F
True
54
When you create a new object that will require the creation of multiple instances of that object, it is best to create a “template” of that object by using a(n) ___________________. a. object template function b. compound instances assignment c. object constructor function d. direct object assignment
c. object constructor function
55
Creating an object instance is known as _______________ an object. a. templating b. compounding c. instantiating d. constructing
c. instantiating
56
JavaScript provides a means to modify objects to include new methods and/or properties and also to create all new objects based on ones that already exist. T F
True
57
The _____________ object allows you to add a property or method that then becomes available for all instances of the object. a. pattern b. architype c. compound d. prototype
d. prototype
58
_____________ is the capability to hide data and instructions inside an object. a. Encapsulation b. Assimilation c. Consolidation d. Integration
a. Encapsulation
59
Any variables or functions that are declared within the constructor function are available from either inside or outside of the object. T F
False
60
A __________ acts as a template or blueprint for the creation of objects. a. function b. class c. event d. all of the above can be used depending upon the application
b. class
61
A __________ function creates and initializes an object instance of a class. a. inheritance b. prototype c. event d. constructor
d. constructor
62
A class constructor cannot be called without using the new keyword. T F
True
63
4. Which statement is NOT true when using set: a. it only requires one argument ( newName ) b. it updates the value of a variable c. it can only be applied once in your code d. called when the property value is actually being assigned ( set )
c. it can only be applied once in your code
64
Which statement is NOT true when using get: a. it does not require an argument b. it is used to retrieve a property value c. it is only available when also using the set function d. does not evaluate a property’s value until it is accessed
c. it is only available when also using the set function
65
A(n) __________ is a unique data type used that is useful for naming object properties that cannot later be overwritten. a. symbol b. class c. prototype d. instance
a. symbol
66
A symbol data type is basically similar to a string and so the same functionality applies to both. T F
False
67
The _______ keyword is used in the constructor and acts as a reference variable to the parent class and is used to inherit all of its properties. a. set b. get c. extends d. super
d. super
68
The _______ keyword is used to create a class as a child of another class. a. set b. get c. extends d. super
c. extends
69
Another way to utilize browser detection is to have JavaScript examine whether or not a specific feature you need is supported by testing for the availability of a specific object, method or property through the browser’s version. T F
True
70
The top-level object in the DOM is the ___________ object. a. document b. window c. browser d. screen
b. window
71
An advantage of using the DOM is that the DOM is always available – even if the page has not yet completely finished loading. T F
False
72
According to the DOM, everything in a web document is a(n) _______ -- which means the entire document, every element, every attribute and even it’s included text can all be classified as one of these. a. characteristic b. architype c. compound d. node
d. node
73
Each different type of node has an associated number known as its _______ _________ property. a. nodeType b. nodeModel c. nodeID d. nodeDesignation
a. nodeType
74
Which of the following statements is NOT true about the childNodes property: a. It is useful for each node in a collection. b. The results are returned as an indexed array. c. You can use all string and array methods on the returned results. d. It allows you to access information about the immediate children of any DOM node.
c. You can use all string and array methods on the returned results.
75
After running the childNodes property, you can use the shorthand method ____________ to access the first element in the results; and you can use the shorthand method _____________ to access the last. a. firstParent ; lastParent b. firstElement ; lastElement c. firstChild ; lastChild d. firstNode ; lastNode
c. firstChild ; lastChild
76
The childNodes property returns the parent node of the node to which it is applied. T F
False
77
________ and ________ are methods that can be applied to a specific parent node in order to return the return the following and previous sibling nodes. a. nextSibling ; previousSibling b. nextChild ; previousChild c. followingSibling ; priorSibling d. followingChild ; priorChild
a. nextSibling ; previousSibling
78
The __________ property returns the value stored in a node. a. nodeContent b. nodeValue c. getNodeContent d. getNodeValue
b. nodeValue
79
The nodeName property returns the name of the specified node as a _______ value and is ________________________. a. array ; read-only and cannot be changed at all b. string ; read-only and cannot be changed at all c. array ; changeable using the standard array methods d. string ; changeable using the standard string methods
b. string ; read-only and cannot be changed at all
80
The ________________ method allows you to build an array populated with all of the occurrences of a particular tag. a. getTagsByElementName( ) b. getTagByElementName( ) c. getElementsByTagName( ) d. getElementByTagName( )
c. getElementsByTagName( )
81
In referencing the method referred to in question #29, you do not have to always apply it to the entire document; it can be applied to any individual object and will return a collection of elements with the given tag name contained within that object. T F
True
82
Attributes are child nodes of the element node in which they appear. T F
True
83
The _____________ method lets you read the attribute value of any node that you have accessed. a. getTagAttributes( ) b. getAttributes( ) c. getTagAttribute( ) d. getAttribute( )
d. getAttribute( )
84
You can test whether or not an element has a particular attribute value defined, and if it does not, it will return a value of null. T F
True
85
To create a new "p" element, you would use the following code: a. document.createElement(“p”); b. document.makeElement(“p”); c. document.createElement(p); d. document.makeElement(p);
a. document.createElement(“p”);
86
To add text content to a web page element, you would use the _______ method. a. createTextNode( ) b. makeTextNode( ) c. addTextNode( ) d. appendTextNode( )
a. createTextNode( )
87
If you already have a node in your document that is just like the one you want to create, you can use the ____________ method to do so. a. nodeClone( ) b. nodeCopy( ) c. cloneNode( ) d. copyNode( )
c. cloneNode( )
88
If you want to make an exact copy of a node already in your document, including all of its child nodes, you would call the correct method and pass it the value T F
False
89
If you wish to add a new node to an existing node already in your document, an easy way is to use the ___________ method to append it to that node. a. addChild( ) b. appendChild( ) c. attachChild( ) d. joinChild( )
b. appendChild( )
90
The method that is referred to in question 38 always adds the new node before the first child node that is already present – therefore, the new node becomes the first child node of the parent node. T F
False
91
When working with document nodes, which of the following methods is NOT a real method that can be used: a. insertAfter( ) b. replaceChild( ) c. insertBefore( ) d. removeChild( )
a. insertAfter( )
92
To set the id attribute of a
tag to “part1”, which code would you use: a. setAttribute( “id”, “part1” ) b. setAttribute( id, part1 ) c. setAttribute( “part1”, “id” ) d. setAttribute( part1, id )
a. setAttribute( “id”, “part1” )
93
Setting the value of an existing attribute effectively overwrites the value of that attribute. T F
True
94
JSON ( JavaScript Object Notation ) is an open-standard format that uses human-readable text to transmit data objects consisting of attribute–value pairs. T F
true
95
Once expressed in JSON, JavaScript objects can easily be converted to strings and then interpreted as JavaScript code. T F
True
96
In JSON, when expressing your data as a sequence of parameters and value pairs, the ______ character is used to separate parameter from value. a. | ( pipe ) b. = ( equal ) c. ; ( semicolon ) d. : ( colon )
d. : ( colon )
97
In JSON, when listing several sequences of parameters and value pairs, the ______ character is used to separate one pair from another. a. | ( pipe ) b. , ( comma ) c. ; ( semicolon ) d. : ( colon )
b. , ( comma )
98
When creating a JSON object, the data pairs are enclosed in ____ as a group. a. “ “ ( single or double quotes ) b. [ ] ( square braces ) c. { } ( curly braces ) d. ( ) parenthesis
c. { } ( curly braces )
99
Not only objects, but any data that can be expressed as a series of parameter and value pairs can be expressed in JSON notation. T F
True
100
The term deserializing the string refers to: a. the process of converting a JSON data string back into JavaScript code b. the process of converting a string of JavaScript code into the JSON data format c. the process of debugging JSON data before adding it to JavaScript code d. the process of converting JSON data structures into the XML data format
a. the process of converting a JSON data string back into JavaScript code
101
The _____ function can be used to convert a JSON string in a JavaScript object. a. eval( ) b. convert( ) c. changeData( ) d. modify( )
a. eval( )
102
All browsers include native JSON support; this means that, by default, they create a JavaScript object called JSON to manage JSON decoding and encoding. T F
False
103
The ____________ method takes a string containing a JSON-serialized object and breaks it up, creating an object with properties corresponding to the string’s parameter and value pairs. a. modify.JSON( ) b. parse.JSON( ) c. JSON.parse( ) d. JSON.modify( )
c. JSON.parse( )
104
___________ is the process of converting data into a format that can be stored or transmitted across a network and recovered later into the same format as the original. a. Modification b. Serialization c. Parsing d. Initialization
b. Serialization
105
. The JSON.stringify() method converts a JavaScript value to a JSON string. T F
True
106
Which of the following statements is NOT one of the rules that must be followed when creating / naming the parameter part of the parameter and value pair: a. It cannot be a JavaScript reserved keyword. b. It must not start with a number. c. It must not include any special characters except the underscore or dollar sign. d. It cannot consist of less than 3 or more than 16 characters.
d. It cannot consist of less than 3 or more than 16 characters.
107
As is the case with other programming languages, JavaScript fully supports the usage of associative arrays. T F
False
108
The code syntax: object[“property”] and object.property are equivalent in JavaScript. T F
True
109
Although it was developed for describing JavaScript objects, JSON is independent of any language or platform; libraries and tools exist for other programming languages such as C, PHP and Java. T F
True
110
_____________ is the code that you would use in JSON to create an “empty” instance of an object which contains no properties or methods. a. var firstObject = [ ]; b. var firstObject = { }; c. var firstObject = ( ); d. var firstObject = “ “;
b. var firstObject = { };
111
It is safer to use a browser with a native JSON parser to convert a JSON string into a JavaScript object; this is because a JSON parser will recognize only JSON text and will not execute script commands. T F
True