






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
JAVASCRIPT CIW Exam Questions and Answers Latest Graded A+
Typology: Exams
1 / 10
This page cannot be seen from the preview
Don't miss anything!







You want to include in your form a button labeled Edit, which changes to Save when in edit mode and changes back to Edit when the form contents are saved. You are calling a function from the onclick event handler to perform this task. Which of the following is the correct code for that function? - ✔✔if(myButton.value =="Edit") { myButton.value = "Save"; } else{ myButton.value = "Edit"; } Which of the following is a valid variable name in JavaScript? - ✔✔sink Which of the following correctly defines an object with a property called height, a property called width, and a method called getArea? - ✔✔function objRectangle(height, width) { this.height = height; this.width = width; this.getArea = getArea; } Consider the following expression: x = 25; y = 10; Which statement would evaluate to true? - ✔✔x > = y; You work for a mid-size company with a large Web site that has a very wide customer base. Which is the best method for testing your JavaScript code for this site? - ✔✔Test in various browsers, versions and operating systems. Consider the following code:
What is the expected result when this script is run in the browser? - ✔✔Two alert boxes, both displaying Green What is a pop-up blocker? - ✔✔A browser-level security feature Consider the following statement: Cookies can be used to store passwords so authentication is not necessary for returning users. Which of the following choices about this statement is accurate? - ✔✔The statement is true, but this practice poses a security risk. Which code will correctly declare the calendarYear variable as a date object? - ✔✔var calendarYear = new Date(); Consider the following code:
Your site has a page that uses AJAX to refresh a portion of the content based on the user's action. A user has made a selection on this page and is waiting for a response. While waiting, she changes her mind and makes a different selection before receiving a response for her first selection. She is confused when the eventual response does not seem to match her second action. This example shows what type of disadvantage to using AJAX in a Web page? - ✔✔Server response issue What is the purpose of a signed script? - ✔✔A signed script allows the client to validate JavaScript to prove the identity of the author. Consider the following code: var myVar = (3 < 5)? 3 : 5; What is the value of myVar after execution of this script? - ✔✔The value of myVar will be: 3 How can you avoid infinite loops in your Web pages? - ✔✔By including conditions that will cause your for statements to finish Which statement about the getElementsByName() method is true? - ✔✔It returns an array containing all elements with the specified name. Which event handler of the select object specifies the JavaScript code to execute when the select object loses focus after a user makes a selection, but only if the user selects an option other than the default? - ✔✔onchange Consider the following code: var nurseryRhyme = "Mary had a little lamb"; How would you find the position of the last letter "a" in the given string? - ✔✔nurseryRhyme.lastIndexOf("a");
In an AJAX transaction, which readyState value indicates that the XMLHttpRequest has been sent but no response has been received yet? - ✔✔readyState value 2 What is the basis for the JavaScript form object? - ✔✔The form object is based on the X/HTML form element. Consider the following code: var firstArray = ["Sabrina", "Kelly", "Jill"] var secondArray = firstArray; secondArray = secondArray.join("Kris"); alert(secondArray); What is the output when this script is run in the browser? - ✔✔An alert box that displays: SabrinaKrisKellyKrisJill Which JavaScript event handler is triggered when a user clicks her mouse button outside of a particular field after typing input there? - ✔✔onblur Consider the following code:
What's your favorite color?
Red Orange Purple
Cross-site scripting (XSS) is a type of: - ✔✔code-injection attack. Consider the following code: var firstArray = ["Sabrina", "Kelly", "Jill"] var secondArray = firstArray.pop(); alert(secondArray); What is the output when this script is run in the browser? - ✔✔An alert box that displays: Jill Consider the following code:
What will be the output of this switch statement when it is run in the browser? - ✔✔My pet is a Rabbit. My pet is a Frog. I do not have a pet.
Which choice lists two main advantages of AJAX? - ✔✔Reduced bandwith use and faster page loading You have a page containing personal contacts on your system at work. Although the information is not highly sensitive, you want to protect it from easy access by co-workers who might use your computer occasionally. You decide to script a cookie to password-protect this document. Which statement should you use in the cookie code to check your chosen password against the user input in a password field and either permit or deny the user to see the protected page? - ✔✔if...else statement Which example demonstrates correct syntax for declaring a string variable? - ✔✔var _greeting; Consider the following code: for (X; Y; Z) What does Y represent in this statement? - ✔✔The condition under which the loop will execute In an AJAX transaction, which role does XHTML play? - ✔✔It displays the application on the page to the user. Which JavaScript form object supports the checked property? - ✔✔radio Consider the following code: var myVar = 2; myVar += "3"; What is the value of myVar after execution? - ✔✔The value of myVar will be: 23 Which operator denotes that the left operand should not equal the right operand? - ✔✔!= Consider the following line of code:
Which of the following is an event handler for the button object? - ✔✔onclick Consider the following code:
What is the expected outcome if the preceding function is called from an onclick event in the tag?