CS 250 MIDTERM QUESTIONS AND ANSWERS
Symbols such as + and * used in expressions to manipulate operands are known as
____. - Answer -operators
Special words that are part of the JavaScript language syntax and that can't be used as
variable names are known as ____. - Answer -reserved words
What are the advantages of using the addEventListener() method instead of the other
two methods to specify an event handler? - Answer -The usage of addevent listen
allows for better security features as well as adds more help with detecting errors within
the statement
addEventListener() has multiple advantages: Allows you to register unlimited events
handlers and remove them with element. removeEventListener() . Has useCapture
parameter, which indicates whether you'd like to handle event in its capturing or
bubbling phase.
There are several advantages of using the addEventListener() method instead of the
other two methods to specify an event handler in JavaScript:
Multiple Event Handlers: With addEventListener(), you can specify multiple event
handlers for a single element. This is useful if you want to run different code in response
to the same event, depending on the context.
Event Order: Using addEventListener() allows you to specify the order in which event
handlers will be executed, whereas the other two methods do not.
Event Capturing and Bubbling: The addEventListener() method supports both event
capturing and bubbling, allowing you to specify whether an event handler should be
executed on the capturing phase (working from the outermost element to the innermost)
or the bubbling phase (working from the innermost element to the outermost).
Cross-browser Compatibility: The addEventListener() method is supported in all modern
browsers, including Internet Explorer, Firefox, Safari, and Google Chrome, which makes
it a more reliable and cross-browser compatible option than the other two methods.
In summary, using the addEventListener() method is the recommended way to specify
event handlers in JavaScript, as it offers a more versatile, reliable, and flexible approach
to event handling.
Discuss case sensitivity in JavaScript. - Answer -Case sensitivity is when you use the
same lettering but one in caps and one in lowercase aren't the same thing
JavaScript is a case-sensitive language. This means that language keywords, variables,
function names, and any other identifiers must always be typed with a consistent
capitalization of letters. The while keyword, for example, must be typed "while", not
"While" or "WHILE".
,Elements that do not require a closing tag are called empty elements. - Answer -True
Sending arguments to the parameters of a called function is called
____________________ arguments. - Answer -Passing
Explain what a library is and what it is used for, and name one commonly used library. -
Answer -a library is a code base written by others that you can import into your program
which allows you to use functions methods classes within the codebase without having
to write it over again by your self
A library is a collection of pre-written code that provides additional functionality to a
program. Libraries are used to reduce the amount of time and effort required to write
code for common tasks, and to allow developers to reuse code across multiple projects.
A commonly used library is jQuery. jQuery is a fast, small, and feature-rich JavaScript
library. It makes things like HTML document traversal and manipulation, event handling,
and animation much simpler with an easy-to-use API that works across a multitude of
browsers. With a combination of versatility and extensibility, jQuery has changed the
way that millions of people write JavaScript.
____ refers to programming using a scripting language that is executed from a web
server. - Answer -Server-side scripting
You can place script elements in either the document head or in the document body. -
Answer -True
The strict equal operator is ____. - Answer -===
A single statement that declares a variable and specifies array values as its content is
called an array ____. - Answer -literal
Placing one decision-making statement within another decision-making statement
creates a(n) ____________________ decision-making structure - Answer -nested
The conditional expression in the while statement is enclosed within ____ following the
keyword while. - Answer -parentheses
Explain how you access an element's value in an array. - Answer -you can accesses an
elements value within a array by calling the array by its name than after the putting []
and the number index you want to access the element
Once your arrays are declared, you access the elements in an array with the array
name, and the index number inside brackets [ ]. If an array is declared as: typeName
varName[size], then the element with index n is referred to as varName[n].
Which method returns a collection of references to all instances of a certain element in
an HTML document? - Answer -getElementsByTagName()
, Each piece of data contained in an array is called a(n) ____. - Answer -element
You access an array element's value just as you access the value of any other variable,
except that you include the element index in brackets. - Answer -True
In a(n) ____________________ loop, a loop statement never ends because its
conditional expression is never falsy - Answer -infinite
An if statement keeps repeating until its conditional expression evaluates to false. -
Answer -False
The ____ label contains statements that execute when the value returned by the switch
statement expression does not match a case label. - Answer -default
What is the difference between a variables list and a watch list in browser debugging
tools? - Answer -A watch list is variables that are chosen by you to watch to see if they
through an error where as a variable list is all variables in a program that get watched.
A variable list help you see how different valyes in the executing function affect program
execution. A watch list is a list of expressions whose values are displayed adn updated
throughout execution of a program.
In browser debugging tools, the difference between a variable list and a watch list is that
a variable list displays the current values of all variables in the current scope, while a
watch list allows you to specifically monitor the values of a select few variables.
A variable list typically displays all of the variables that are currently in scope, along with
their values. This can be useful for getting a quick overview of the state of your
program, but it can also be overwhelming if you have many variables, or if the values of
some of the variables are complex data structures.
A watch list, on the other hand, allows you to select specific variables that you want to
monitor, and the values of those variables will be displayed in the watch list. This can be
more efficient and easier to use than a variable list, as you can focus on only the
variables that are most relevant to your current task.
Additionally, many browser debugging tools allow you to set breakpoints and stop
execution when the value of a variable in your watch list changes. This can be useful for
tracking down bugs and understanding how your code is executing, as you can see
exactly when and why a variable changes value.
In summary, a variable list and a watch list serve different purposes in browser
debugging tools. A variable list provides a broad view of all variables in the current
scope, while a watch list allows you to specifically monitor the values of a select few
variables.
You implement custom error handling using the ____________________ event. -
Answer -error or onerror
Symbols such as + and * used in expressions to manipulate operands are known as
____. - Answer -operators
Special words that are part of the JavaScript language syntax and that can't be used as
variable names are known as ____. - Answer -reserved words
What are the advantages of using the addEventListener() method instead of the other
two methods to specify an event handler? - Answer -The usage of addevent listen
allows for better security features as well as adds more help with detecting errors within
the statement
addEventListener() has multiple advantages: Allows you to register unlimited events
handlers and remove them with element. removeEventListener() . Has useCapture
parameter, which indicates whether you'd like to handle event in its capturing or
bubbling phase.
There are several advantages of using the addEventListener() method instead of the
other two methods to specify an event handler in JavaScript:
Multiple Event Handlers: With addEventListener(), you can specify multiple event
handlers for a single element. This is useful if you want to run different code in response
to the same event, depending on the context.
Event Order: Using addEventListener() allows you to specify the order in which event
handlers will be executed, whereas the other two methods do not.
Event Capturing and Bubbling: The addEventListener() method supports both event
capturing and bubbling, allowing you to specify whether an event handler should be
executed on the capturing phase (working from the outermost element to the innermost)
or the bubbling phase (working from the innermost element to the outermost).
Cross-browser Compatibility: The addEventListener() method is supported in all modern
browsers, including Internet Explorer, Firefox, Safari, and Google Chrome, which makes
it a more reliable and cross-browser compatible option than the other two methods.
In summary, using the addEventListener() method is the recommended way to specify
event handlers in JavaScript, as it offers a more versatile, reliable, and flexible approach
to event handling.
Discuss case sensitivity in JavaScript. - Answer -Case sensitivity is when you use the
same lettering but one in caps and one in lowercase aren't the same thing
JavaScript is a case-sensitive language. This means that language keywords, variables,
function names, and any other identifiers must always be typed with a consistent
capitalization of letters. The while keyword, for example, must be typed "while", not
"While" or "WHILE".
,Elements that do not require a closing tag are called empty elements. - Answer -True
Sending arguments to the parameters of a called function is called
____________________ arguments. - Answer -Passing
Explain what a library is and what it is used for, and name one commonly used library. -
Answer -a library is a code base written by others that you can import into your program
which allows you to use functions methods classes within the codebase without having
to write it over again by your self
A library is a collection of pre-written code that provides additional functionality to a
program. Libraries are used to reduce the amount of time and effort required to write
code for common tasks, and to allow developers to reuse code across multiple projects.
A commonly used library is jQuery. jQuery is a fast, small, and feature-rich JavaScript
library. It makes things like HTML document traversal and manipulation, event handling,
and animation much simpler with an easy-to-use API that works across a multitude of
browsers. With a combination of versatility and extensibility, jQuery has changed the
way that millions of people write JavaScript.
____ refers to programming using a scripting language that is executed from a web
server. - Answer -Server-side scripting
You can place script elements in either the document head or in the document body. -
Answer -True
The strict equal operator is ____. - Answer -===
A single statement that declares a variable and specifies array values as its content is
called an array ____. - Answer -literal
Placing one decision-making statement within another decision-making statement
creates a(n) ____________________ decision-making structure - Answer -nested
The conditional expression in the while statement is enclosed within ____ following the
keyword while. - Answer -parentheses
Explain how you access an element's value in an array. - Answer -you can accesses an
elements value within a array by calling the array by its name than after the putting []
and the number index you want to access the element
Once your arrays are declared, you access the elements in an array with the array
name, and the index number inside brackets [ ]. If an array is declared as: typeName
varName[size], then the element with index n is referred to as varName[n].
Which method returns a collection of references to all instances of a certain element in
an HTML document? - Answer -getElementsByTagName()
, Each piece of data contained in an array is called a(n) ____. - Answer -element
You access an array element's value just as you access the value of any other variable,
except that you include the element index in brackets. - Answer -True
In a(n) ____________________ loop, a loop statement never ends because its
conditional expression is never falsy - Answer -infinite
An if statement keeps repeating until its conditional expression evaluates to false. -
Answer -False
The ____ label contains statements that execute when the value returned by the switch
statement expression does not match a case label. - Answer -default
What is the difference between a variables list and a watch list in browser debugging
tools? - Answer -A watch list is variables that are chosen by you to watch to see if they
through an error where as a variable list is all variables in a program that get watched.
A variable list help you see how different valyes in the executing function affect program
execution. A watch list is a list of expressions whose values are displayed adn updated
throughout execution of a program.
In browser debugging tools, the difference between a variable list and a watch list is that
a variable list displays the current values of all variables in the current scope, while a
watch list allows you to specifically monitor the values of a select few variables.
A variable list typically displays all of the variables that are currently in scope, along with
their values. This can be useful for getting a quick overview of the state of your
program, but it can also be overwhelming if you have many variables, or if the values of
some of the variables are complex data structures.
A watch list, on the other hand, allows you to select specific variables that you want to
monitor, and the values of those variables will be displayed in the watch list. This can be
more efficient and easier to use than a variable list, as you can focus on only the
variables that are most relevant to your current task.
Additionally, many browser debugging tools allow you to set breakpoints and stop
execution when the value of a variable in your watch list changes. This can be useful for
tracking down bugs and understanding how your code is executing, as you can see
exactly when and why a variable changes value.
In summary, a variable list and a watch list serve different purposes in browser
debugging tools. A variable list provides a broad view of all variables in the current
scope, while a watch list allows you to specifically monitor the values of a select few
variables.
You implement custom error handling using the ____________________ event. -
Answer -error or onerror