JS Chapter 1 Review
What would you place in the blank in the following JavaScript code to insert a note for other programmers to read that the interpreter would ignore? script document.write "today's stock prices"; /script
// Need to replace with dynamic content
Which of the following is a characteristic of an object used in JavaScript programming?
includes both programming code and data
A variable used in a program written in JavaScript _____.
is a specific location in the computer's memory
Using client-side scripting to handle light processing tasks such as data validation _____.
is not possible, as you must use server-side scripting to validate forms
When a variable is declared and initialized with the statement var velocity = 32;, this means that _____.
it has a somewhat different scope than if it were declared using the let keyword
Suppose you have initialized two variables containing integers called qtyOne and qtyTwo. How would you write a JavaScript expression to declare a totalQty variable and assign the sum of qtyOne and qtyTwo as its value?
let totalQty = qtyOne + qtyTwo;
Suppose you want to change the source file for the image element with the id value shirtPhoto so that a blue shirt is shown when the webpage user clicks a blue swatch image on the page. The photo's file name is stored in the variable blueShirtImage. What JavaScript event handler could you attach to the swatch image element?
make sure to look at syntax of each option
Which of the following languages is used for server-side scripting?
ruby
What code lines would you place before and after a set of JavaScript statements to embed them in an HTML file?
script /script
A key characteristic that sets scripting languages apart from other programming languages is that _____.
scripting languages are run directly from a program, not compiled
Which of the following JavaScript statements will NOT succeed in declaring the speedLimit variable and assigning the value of 70 to it?
speedLimit = 70; let speedLimit;
In JavaScript, _____.
the statement document.write("Today's special: dumplings!"); can be used to display a message on a web page
Server-side scripting is used to _____.
translate a request from a client into HTML
An HTML document that is well formed and correctly written according to the element definitions in HTML's specific language definition is considered a valid document.
true
Enclosing embedded JavaScript statements within a script element of an XHTML document in a CDATA section causes them to be treated as parsed character data, which will invalidate the XHTML document.
true
JavaScript libraries such as Node.js and jQuery can be downloaded and then utilized to create and manage large web applications more effectively when connected to the HTML file through a script element in the head section.
true
Programmers are not required to end JavaScript statements with semicolons, but it is considered good practice to do so.
true
The JavaScript window.alert() method makes a dialog box appear that contains the literal string passed to it plus an OK button that can be clicked to close the box.
true
The operands in the JavaScript expression "ABC" + 123 + doReMe are: "ABC", 123, and doReMe.
true
When the file magnolia.js is attached to a web page by inserting the following line into its HTML file, the browser will load the HTML and JavaScript files together until the script is loaded, pause loading of the HTML to process the script, then complete loading of the HTML. script src = magnolia.js async /script
true
You should add the defer attribute to the script element attaching an external JavaScript file to an HTML file when you want the browser to load the HTML file completely, then load and process the script.
true
JavaScript _____.
was once supported by Internet Explorer only in a different form called JScript
Suppose you have initialized a variable in your JavaScript program using this statement: let weight = 130; What expression should you use to modify the value of weight later in the program?
weight = 115;
If all of the major browsers can render a web page, this indicates that the HTML document used to produce it is well formed.
false
It is the best practice to place all JavaScript scripts at the beginning of an HTML file so that they will not be run until after the Document Object Model has been created.
false
JavaScript programmers must include code to respond to the complete set of trigger events in each script because all events occur with all devices that run browser applications.
false
When the following script element is inserted into an HTML file to instruct the browser to load a JavaScript file, the name and location of the HTML file belong in the blank.
false
When you insert several JavaScript scripts into an HTML file, you must repeat statements declaring and initializing variables in each script because the statements in one script are unavailable to other scripts in the file.
false
When you link an HTML file to an external JavaScript file using the src attribute of the script element, you must update the HTML file every time the script is modified to prevent load-time errors.
false
Which JavaScript statement calls a method associated with the hotChocolate object, passing the argument 1 to this method?
hotChocolate.addToOrder(1);
Which JavaScript statement assigns the value 3.49 to the price property of the hotChocolate object?
hotChocolate.price = 3.49;
What is the relationship between JavaScript and ECMAScript?
JavaScript is the most important implementation of ECMAScript.
Which statement is correct?
A markup language called HTML is used to define the content and structure of a web page.
What is the role of the IDE in a JavaScript developer's workflow?
It is used to manage all aspects of website development, including writing and testing code.
A code editor _____.
color codes the entered text to denote JavaScript keywords and user-defined values
A(n) _____ transforms a set of instructions written in a programming language into machine code, which can be understood by a computer.
compiler
Which statement should you use to declare a variable called accelerationOfGravity that will store a constant value that cannot be changed?
const accelerationOfGravity = 9.8;
The Document Object Model _____.
describes how to access the contents of a web page and user actions within that page
What is an API?
a set of procedures that access an application
You can use the addition operator (+) in several ways in JavaScript. However, you CANNOT use the addition operator to _____.
add the integer 10 and the string "10" to return the integer 20
Which of the following lists contains only JavaScript keywords?
await, delete, enum, interface
