JavaScript Domain 1-4

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Consider the following code: <script type= "javascript/text "> function mySum(a, b) { ...(your selection here) } alert(mySum(2,3)); </script> Which of the following properly supplies the alert with the sum of the two numbers? return a+b; mySum (a+b); return sum(a+b); return sum;

return a+b; The sum variable mentioned is not defined so it would not return the value of the sum of the two variables. The other answers are wrong because they do not perform addition (not because they do not return a value) - both try to call a function, but will not complete it correctly because of the syntax. return a+b; The sum variable mentioned is not defined so it would not return the value of the sum of the two variables. The other answers are wrong because they do not perform addition (not because they do not return a value) - both try to call a function, but will not complete it correctly because of the syntax.

Which code will correctly declare the blueSkyvariable as a Boolean data type? var blueSky = "true"; boolean blueSky = true; boolean blueSky = "true"; var blueSky = true;

var blueSky = true; In JavaScript, all variables are declared with the var keyword. Placing an item within quote marks instructs JavaScript to store the value as a literal string rather than a value type. A Boolean data type is set as either true or false, without using quotes, because quotes would set it as the word true or false (a string) rather than the Boolean value true or false.

Consider the following code using a checkbox object: <html> <head> <title>Check Box Confirm</title> <script type="text/javascript"> function confirmBox() { if (document.forms[1].checkThis.checked) { alert("The box is checked."); } else { alert("The box is not checked at the moment."); } } </script> </head> <body> <form> <input checked="checked" id="checkThis" z-index="1" type="checkbox" name="checkThis"/> Select the check box<br/> <input type="button" value="Confirm Box" onclick="confirmBox()"/> </form> </body> </html> What will happen when the Confirm Box button is clicked?

An error will return because the wrong form is identified in the if statement.

Consider the following code: <script type="text/javascript"> var message = "Hello ",message2 = "World"; document.write(message + message2); </script> What will be the result of this script when run in the browser? Hello World An error, because concatenation requires the & operator An error, because the variables are not properly declared Hello

Hello World The concatenation operator ( + ) is correct and the variables are declared with shorthand.

Consider the following line of code: <script type="text/javascript" src="Code.js"> What does this line of code do? Opens a JavaScript block and gives credit for the code to a file named Code.js Opens a JavaScript block using code from an external JavaScript file named Code.js Opens a JavaScript block and directs the browser to save all code created by user interaction to a file named "Code.js" Converts a JScript file named "Code.js" to JavaScript code within an X/HTML file

Opens a JavaScript block using code from an external JavaScript file named Code.js

Consider the following code: <script type="text/javascript"> var v1 = "Blue"; function f () { this.v1 = "Green"; alert (this.v1); } f(); alert (v1); </script> What is the expected result when this script is run in the browser? Two alert boxes, the first displaying Blue and the second displaying Green Two alert boxes, the first displaying Green and the second displaying Blue Two alert boxes, both displaying Blue Two alert boxes, both displaying Green

Two alert boxes, both displaying Green The addition of the this keyword in front of v1 allows the function to alter the global declaration of the variable.

Which variable data type is a variable that has not yet had a value assigned to it? Undefined String Null Boolean

Undefined The undefined data type occurs when a variable has no value assigned yet. The null value is a special keyword for when a user enters nothing in a text box then submits the form: The text box has null value. A Boolean data type value is true or false. A string data type is any string of alphanumeric characters.

In JavaScript, which term describes a specific quality of a property? Object Value Method Event

Value Values are the specific qualities of properties. For instance, the statement color="red" assigns a value (red) to a property (color) of an object.

Consider the following code: <form name="myForm"> Yes <input type="checkbox" name="question" value="YES"/> or No <input type="checkbox" name="question" value="No"/> <input type="button" value="Select" onclick="alert(); "/> </form> How would you reference the checkbox parameter that indicates whether or not the box has been selected?

document.myForm.getElementsByTagName('input').question[0].checked

Which JavaScript object can be affected by the onabort event handler? body load image frame

image The abort event occurs when the loading of an image object is stopped, triggering the onabort event handler.


संबंधित स्टडी सेट्स

cornett financial accounting quiz five and six

View Set

Exam Prem CompTIA A+ 220-1102 Practice - Set A Part 1

View Set

Poetic Devices- Match Term to Examples

View Set

Lesson One: OSI anD TCP/IP Modle

View Set

Traditional Hawaiian Metaphors Worksheet

View Set