Js

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Js as PDF for free.

More details

  • Words: 1,542
  • Pages: 13
Quiz Questions Test your knowledge of JavaScript by answering the following questions: 1.Why do JavaScript and Java have similar names? a. JavaScript is a stripped-down version of Java. b. Netscape's marketing department wanted them to sound related. c. They botoriginated on the island of Java. 2.When a user views a page containing a JavaScript program, which machine actually executes the script?

a. The user's machine running a web browser b. The web server c. A central machine deep within Netscape's corporate offices 3.Which of the following languages is supported by both Microsoft Internet Explorer and Netscape? a. VBScript b. ActiveX c. JavaScript

Quiz Answers 1.b. Although some of the syntax is similar, JavaScript got its Java-based name mostly because of a marketing relationship. 2.a. JavaScript programs execute on the web browser. (There is actually a server-side version of JavaScript, but that's another story.) 3.c. JavaScript is supported by both Netscape and Internet Explorer, although the implementations are not identical.

Quiz Questions Test your knowledge of JavaScript by answering the following questions: 1.What software do you use to create and edit JavaScript programs? a. A browser b. A text editor c. A pencil and a piece of paper 2.What are variables used for in JavaScript programs? a. Storing numbers, dates, or other values b. Varying randomly c. Causing high school algebra flashbacks 3.What should appear at the very end of a JavaScript script embedded in an HTML file? a. The <script LANGUAGE="JavaScript"> tag b. The tag c. The END statement

Quiz Answers 1.b. Any text editor can be used to create scripts. You can also use a word processor if you're careful to save the document as a text file with the .html or .htm extension. 2.a. Variables are used to store numbers, dates, or other values. 3.b. Your script should end with the tag.

Quiz Questions Test your knowledge of JavaScript by answering the following questions: 1.A script that executes when the user clicks the mouse button is an example of what? a. An object b. An event handler c. An impossibility 2.Which of the following are capabilities of functions in JavaScript? a. Accept parameters b. Return a value c. Both of the above 3.Which of the following is executed first by a browser? a. A script in the section b. A script in the section

c. An event handler for a button

Quiz Answers 1.b. A script that executes when the user clicks the mouse button is an event handler. 2.c. Functions can accept both parameters and return values. 3.a. Scripts defined in the section of an HTML document are executed first by the browser.

Quiz Questions Test your knowledge of JavaScript by answering the following questions: 1.Which of the following objects can be used to load a new URL into the browser window? a. document.url b. window.location c. window.url

2.Which object contains the alert() method? a. window b. document c. location

3.Which of the following DOM levels describes the objects described in this hour? a. DOM level 0 b. DOM level 1 c. DOM level 2

Quiz Answers 1.b. The window.location object can be used to send the browser to a new URL. 2.a. The window object contains the alert() method. 3.a. The objects described in this hour fall under the informal DOM level 0 specification

Quiz Questions Test your knowledge of JavaScript by answering the following questions: 1.Which of the following is not a valid JavaScript variable name? a. 2names b. first_and_last_names c. FirstAndLast

2.If the statement var fig=2 appears in a function, which type of variable does it declare? a. A global variable b. A local variable c. A constant variable 3.If the string test contains the value The eagle has landed., what would be the value of test.length? a. 4 b. 21 c. The

4.Using the same example string, which of these statements would return the word eagle? a. test.substring(4,9) b. test.substring(5,9) c. test.substring("eagle")

5.What will be the result of the JavaScript expression 31 + "angry polar bears"? a. An error message b. 32 c. "31 angry polar bears"

Quiz Answers 1.a. 2names is an invalid JavaScript variable name because it begins with a number. The others are valid, although they're probably not ideal choices for names. 2.b. Because the variable is declared in a function, it is a local variable. The var keyword ensures that a local variable is created. 3.b. The length of the string is 21 characters. 4.a. The correct statement is test.substring(4,9). Remember that the indexes start with 0,

and that the second index is noninclusive.

5.c. JavaScript converts the whole expression to the string "31 angry polar bears". (No offense to polar bears, who are seldom angry and rarely seen in groups this large.)

Quiz Questions Test your knowledge of JavaScript by answering the following questions: 1.What JavaScript keyword is used to create an instance of an object? a. object b. new c. instance 2.What is the meaning of the this keyword in JavaScript? a. The current object. b. The current script. c. It has no meaning. 3.What does the prototype keyword allow you to do in a script? a. Change the syntax of JavaScript commands. b. Modify the definitions of built-in objects. c. Modify the user's browser so only your scripts will work

Quiz Answers 1.b. The new keyword creates an object instance. 2.a. The this keyword refers to the current object. 3.b. The prototype keyword allows you to modify the definitions of built-in objects.

Quiz Questions Test your knowledge of JavaScript conditions and loops by answering the following questions. 1.Which of the following operators means "is not equal to" in JavaScript? a. ! b. != c. <>

2.What does the switch statement do? a. Tests a variable for a number of different values b. Turns a variable on or off c. Makes ordinary if statements longer and more confusing 3.Which type of JavaScript loop checks the condition at the end of the loop? a. for b. while c. do…while

4.Within a loop, what does the break statement do? a. Crashes the browser b. Starts the loop over c. Escapes the loop entirely 5.The statement while (3==3) is an example of a. A typographical error b. An infinite loop c. An illegal JavaScript statement

Quiz Answers 1.b. The != operator means is not equal to. 2.a. The switch statement can test the same variable or expression for a number of different values. 3.c. The do…while loop uses a condition at the end of the loop. 4.c. The break statement escapes the loop. 5.b. Because the condition (3==3) will always be true, this statement creates an infinite loop.

Quiz Questions

Test your knowledge of JavaScript libraries and built-in functions by answering the following questions. 1.Which of the following objects cannot be used with the new keyword? a. Date b. Math c. String

2.How does JavaScript store dates in a Date object? a. The number of milliseconds since January 1, 1970 b. The number of days since January 1, 1900 c. The number of seconds since Netscape's public stock offering 3.What is the range of random numbers generated by the Math.random function? a. Between 1 and 100 b. Between 1 and the number of milliseconds since January 1, 1970 c. Between 0 and 1

Quiz Answers 1.b. The Math object is static; you can't create a Math object. 2.a. Dates are stored as the number of milliseconds since January 1, 1970. 3.c. JavaScript's random numbers are between 0 and 1.

Quiz Questions Test your knowledge of JavaScript events by answering the following questions. 1.Which of the following is the correct event handler to detect a mouse click on a link? a. onMouseUp b. onLink c. onClick 2.When does the onLoad event handler for the tag execute? a. When an image is finished loading b. When the entire page is finished loading c. When the user attempts to load another page 3.Which of the following event object properties indicates which key was pressed for an onKeyPress event in Internet Explorer? a. event.which b. event.keyCode

c. event.onKeyPress

Quiz Answers 1.c. The event handler for a mouse click is onClick 2.b. The tag's onLoad handler executes when the page and all its images are finished loading. 3.b. In Internet Explorer, the event.keyCode property stores the character code for each keypress.

Quiz Questions Test your knowledge of the DOM's window features by answering the following questions. 1.Which of the following methods displays a dialog box with OK and Cancel buttons, and waits for a response? a. window.alert b. window.confirm c. window.prompt

2.What does the window.setTimeout method do? a. Executes a JavaScript statement after a delay b. Locks up the browser for the specified amount of time c. Sets the amount of time before the browser exits automatically 3.You're working with a document that contains three frames with the names first, second, and third. If a script in the second frame needs to refer to the first frame, what is the correct syntax? a. window.first b. parent.first c. frames.first

Quiz Answers 1.b. The window.confirm method displays a dialog box with OK and Cancel buttons. 2.a. The window.setTimeout method executes a JavaScript statement after a delay. 3.b. The script in the second frame would use parent.first to refer to the first frame.

Related Documents

Js
June 2020 31
Js
May 2020 34
Js
May 2020 22
Js
June 2020 21
Js
October 2019 39
Js
April 2020 27