In a JavaScript regular expression \d and \D are alternate forms of the same thing.
-False
JavaScript can be used for
-False
JavaScript can be used for
B.
C.
D.
In JavaScript strings may be enclosed in either double quotes or single quotes.
-True
In JavaScript the functions Math.ceil() and Math.round() return the same value for an input of 3.6.
-True
A DOM Link object will be found within which XHTML element?
head
JavaScript programs are compiled.
-False
In a JavaScript regular expression, a single non-digit would be represented by _____.
-\D
Write a small JavaScript function called area that takes one parameter for the radius of a circle and returns the area rounded off to the nearest integer and computed as
.
function area(radius)
{
return Math.round(3.1415*Math.pow(radius,2));
}
{
return Math.round(3.1415*Math.pow(radius,2));
}
The recommended place to put your JavaScript code is __________.
-in an external file
Fill in the truth values in the following truth table:

JavaScript is used for both client-side and server-side computing.
-True
JavaScript originated from the Java programming language.
-False
In JavaScript myArray[1] would refer to the first element of the array myArray.
-False
Give a high-level description of what regular expressions are, and how JavaScript uses them.
Regular expressions form a kind of “pattern language” that provide us with a concise and very powerful technique for “matching” one string against another to see if a given string “matches” a required “pattern”. Since essentially all of the input to our websites through our forms arrives initially as string data, even if it will eventually be interpreted as numerical data, we can therefore use regular expressions to examine this data for potential problems. The idea is, of course, to “validate” the data, in the sense that if the data is what we think it should be, we let it go through; otherwise we reject it. This is useful both for keeping out input that might actually be harmful in some way, as well as for preventing bad data caused by user data-entry error from being sent to the server. In the latter case, recognizing errors on the client side saves on “bandwidth” consumption, since otherwise we would be sending bad data to the server, and the server would have to send back an error message.
The JavaScript symbol for a “logical and” is && .
The DOM object Area is related to which XHTML element?
img
Which of the following is not among our list of JavaScript “escape characters” (also called “special characters”)?
\c
Compare the relative advantages of compiled versus interpreted languages.
Both compiled and interpreted languages make it possible for programmers to write programs in higher-level, English-like languages. Both types of programs need to be translated to machine language instructions before they can be executed by a computer. The compilation process translates the entire program once, and then that “translation” can be executed many times without another translation. Interpreted programs are translated one instruction at a time, at the time of execution, and this translation is repeated for each execution. While there is translation overhead for every execution of an interpreted program, they are easier to modify, and are more easily portable to a wide variety of computing environments.
Which DOM object refers to the entire XHTML document of the web page shown in the user's browser when that user arrives at the home page of your website and displays your index.html file?
Document
If you simply want to output “Hello, world!” to a web page, the JavaScript statement you would use is ________.
document.write("Hello, world!");
document.write("Hello, world!");
In JavaScript myArray[1] would refer to the first element of the array myArray.
-False
In JavaScript strings may be enclosed in either double quotes or single quotes.
-True
-True
JavaScript is mostly concerned with
the behavior of a web page
the behavior of a web page
The acronym DOM stands for
Document Object Model
The acronym API stands for
Application Programming Interface
Document Object Model
The acronym API stands for
Application Programming Interface
Which JavaScript method would you use to notify the user of something with a message in a popup window?
-alert()
-alert()
To give a visitor to your website a message via a “popup” dialog box, you would use the JavaScript _________ method.
alert()
Write a small JavaScript function called volume that takes two parameters, one for the height, another for the radius, and then displays the volume of the corresponding cylinder, as computed by
and rounded off to the nearest integer. For example, a call to the function such as volume(2,5); should produce the following output:

function volume(height, radius)
{
alert("Radius = " + radius + " Height = "
+ height + " Volume of cylinder = "
+ Math.round(3.1415*height*Math.pow(radius,2)));
}
JavaScript placed in an external file must not be enclosed in a script element.
-True
{
alert("Radius = " + radius + " Height = "
+ height + " Volume of cylinder = "
+ Math.round(3.1415*height*Math.pow(radius,2)));
}
JavaScript placed in an external file must not be enclosed in a script element.
-True
In a regular expression, \d{3,7} means
a single digit exactly 3, 4, 5, 6 or 7 times
a single digit exactly 3, 4, 5, 6 or 7 times
The JavaScript symbol for a “logical or” is ___________.
||
|
If, in a regular expression, we wish to match any capital letter in the range from C to F, we should use
B or C above
Describe briefly the purpose and structure of a programmer-defined JavaScript function.
Programmer-defined functions in any programming language, including JavaScript, are a good way to keep your code “modularized”. Each function should be short, and have a clear purpose. This makes your scripts easier to understand, and to modify if required. In JavaScript, a function definition begins with the keyword function, followed by the programmer-chosen name of the function and a pair of parentheses. It is, of course, important to choose a good name for every function. The parentheses may be empty, or may contain a comma-separated list of values to be passed into the function when it is called. This much of the function is called the “function header” and it is followed by a set of braces containing the “body” of the function, consisting of the coded that performs the action, or computes the value, for which the function was defined. If the function does compute a value to be returned to its caller, there must be a return statement (usually, but not always, the last statement) that returns the computed value.
Programmer-defined functions in any programming language, including JavaScript, are a good way to keep your code “modularized”. Each function should be short, and have a clear purpose. This makes your scripts easier to understand, and to modify if required. In JavaScript, a function definition begins with the keyword function, followed by the programmer-chosen name of the function and a pair of parentheses. It is, of course, important to choose a good name for every function. The parentheses may be empty, or may contain a comma-separated list of values to be passed into the function when it is called. This much of the function is called the “function header” and it is followed by a set of braces containing the “body” of the function, consisting of the coded that performs the action, or computes the value, for which the function was defined. If the function does compute a value to be returned to its caller, there must be a return statement (usually, but not always, the last statement) that returns the computed value.
Interpreted programs tend to run faster than compiled programs.
false
false
Explain briefly the statement, “JavaScript can help us to keep our websites secure.”
First of all, note that neither JavaScript nor any other technology can guarantee that our websites will be secure. Hackers are always finding new ways to penetrate even the best of our defences, so we must be constantly vigilant. JavaScript can, however, at least “help” us to thwart potential problems, by helping us to ensure that the kind of data we ask our users to enter into our forms is, in fact, the data that gets entered. If we use regular expressions to “sanitize” data entries and reject those that do not conform to the formats we have requested, this can go some distance toward preventing such things as malicious code being submitted to our websites through our forms.
First of all, note that neither JavaScript nor any other technology can guarantee that our websites will be secure. Hackers are always finding new ways to penetrate even the best of our defences, so we must be constantly vigilant. JavaScript can, however, at least “help” us to thwart potential problems, by helping us to ensure that the kind of data we ask our users to enter into our forms is, in fact, the data that gets entered. If we use regular expressions to “sanitize” data entries and reject those that do not conform to the formats we have requested, this can go some distance toward preventing such things as malicious code being submitted to our websites through our forms.
Write a small JavaScript function called areYouTall that takes one parameter for the height and displays the “popup” message “You are tall!” if the height is greater than or equal to 72.
function areYouTall(height)
{
if (height >= 72)
{
alert("You are tall!");
}
}
function areYouTall(height)
{
if (height >= 72)
{
alert("You are tall!");
}
}
The JavaScript method to use for obtaining access to an object via the id value of that object is _______.
getElementById() (or document.getElementById())
Explain briefly the relationship between JavaScript and the DOM, and indicate why this relationship is so useful.
|
The DOM (Document Object Model) is a hierarchical model of all the elements, attributes and styles on your web page, and it provides a language-independent API (Application Programming Interface) for access to those “objects”. JavaScript is one of many programming languages that takes advantage of this API to gain access to the various parts of a web page to manipulate and modify the “look and feel”, and even the content, of the page, often in response to user interaction with the page (clicking a button, for example). This interaction between JavaScript and the DOM is how we are able to provide a “behavioral” aspect to our web pages, and move them beyond the “static” pages that were the only option in the early days of the web.
In JavaScript, whatever follows the if keyword and comes before the else keyword must be enclosed in braces (also called “curly brackets”).
| |
| True |
The original name for what we now call JavaScript was_____________.
LiveScript
LiveScript
No comments:
Post a Comment