Exam 2 CS2350

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

Identify a syntax to set the time-delayed commands.

setTimeout("command", delay);

Identify a statement that is added to the first line of the file to run a script in strict mode.

"use strict";

Identify a syntax for JavaScript function.

function function_name(parameters){ commands }

Which of the following JavaScript methods is used to define an object collection based on a CSS (Cascading Style Sheets) selector?

document.querySelectorAll(selector)

Which of the following methods is used to determine the day of the week on which a month starts?

getDay()

Identify a true statement about a function in JavaScript.

A function can be stored as a variable.

Which of the following examples tests whether x is equal to 5 or y is equal to 8?

(x === 5) || (y === 8)

Regular expressions have the general form denoted as _____.

/pattern/

Which of the following is the correct value of the charCode property for the keys "a, z" when the keyup and keydown events occur?

0, 0

Identify the output of the following code. var x = [3, 45, 1234, 24]; x.sort();

1234, 24, 3, 45

What is the output of the following code? var sum = 0; var x = [1, 3, 7, 11]; x.forEach(sumArray); function sumArray(value) { sum += value; }

22

In the following code, identify the value of children.length property if article is the element node. <article> <h1>The U.S. Constitution</h1> <h2>Preamble</h2> <p>We the People of the United States, in Order to form a more perfect Union ... </p> </article>

3

Which of the following values will the expression 15 % 4 return?

3

The keyCode values for the keys "1, 9" on the numeric pad when the keypress event occurs is _____.

49, 57

What is the output of the following code? var x = [4, 7, 11]; x.forEach(stepUp); function stepUp(value, i, arr) { arr[i] = value + 1; }

5, 8, 12

Which of the following provides the correct syntax for adding an event handler to a page element as an HTML attribute?

<element onevent = "script">

The _____ operator tests whether two items are equal in value and have the same data type.

= = =

_____ is the process of locating and fixing a programming error.

Debugging

Which of the following methods creates a node containing the text string text?

document.createTextNode(text)

Since a page can contain multiple web forms, JavaScript organizes the forms into _____ object collection.

document.forms[idref]

Which of the following is a true statement about an event listener?

It allows a function to override another when multiple functions are added.

Identify a true statement about the counter variable method for looping through a collection of child nodes.

It enables the child nodes in the for loop to have the object reference as node.childNodes[i]

Identify the description of the option.selected property.

It returns true if the option has been selected by user.

Identify a syntax to access any of the mathematical constants supported by the Math object.

Math.CONSTANT

Which of the following methods of the Math operator rounds x up to the next highest integer?

Math.ceil(x)

Identify a return value for the expression 5/"A" using JavaScript.

NaN

Identify the reason for which <form method="get" action="url"> attribute is added to a form element.

To append form data to the URL

Identify the action for which the g flag is added at the end of the regular expression /pattern/.

To perform a global search

Identify the use of string.indexOf(str [,start])method.

To search for the occurrence of a substring within larger text strings

What is the output of the following code? var scores = [92, 68, 83, 95, 91, 65, 77]; var highScores = scores.filter(gradeA); function gradeA(value) { return value > 90; }

[92, 95, 91]

Which of the following character types is used for any non-white-space character?

\S

William wants to create a dialog box in his website to display the message "My name is William". Which of the following syntaxes must William use to display the message?

alert("My name is William")

Which of the following determines the current size of an array?

array.length

Identify the expression used to reference array values.

array[i]

The _____ attribute tells a browser to parse the HTML and JavaScript code together, only pausing to process the script before returning to the HTML file.

async

To break a text string into several lines, which means that the text string continues on the next line, the _____ character should be used.

backslash

Which of the following statements is used to terminate any program loop or conditional statement?

break

The technique for locating the source of an error is to set up _____, which are locations where the browser will pause the program, allowing the programmer to determine the error at that position.

breakpoints

Numeric data can be sorted by creating a(n) _____ function that contrasts the values of two adjacent array items.

compare

The _____ loop tests the condition to continue the loop right after the latest command block is run.

do/while

Which of the following methods is used to create an attribute node with the name age?

document.createAttribute(age)

The _____ method can be used to create a comment node containing the comment text

document.createComment

Identify the method used to create an element node with the name elm.

document.createElement(elm)

John has created an object called Pines. He wants to change the cursor type to the pointer cursor. Which of the following syntaxes must John use to accomplish this?

document.getElementById("Pines").style.cursor = "pointer";

Which of the following JavaScript expressions is equivalent to the given HTML code?

document.getElementById("menu1").className = "menu";

Identify an expression that can be used to refer an element by its id attribute. Document.getElementbyID(id) document.getelementById(id) Document.getelementByID(id) document.getElementById(id)

document.getElementById(id)

Identify the correct syntax to prevent a submit button from submitting a web form when clicked using the prevent default() method.

document.querySelector("input[type='submit']").onclick = runForm; function runForm(e) { function commands e.preventDefault(); }

Identify a property used to refer an HTML code that is stored within a page element.

element.innerHTML

Which of the following keyboard event properties returns the text of the key used in the event?

evt.key

The _____ is a mouse event object property that references the secondary object, where for the mouseover event, it is the element that the pointer is leaving and for the mouseout event it is the element that the pointer is entering.

evt.relatedTarget

Which of the following event object methods prevents other event listeners of the event from being called?

evt.stopImmediatePropagation()

Identify the mouse event property that returns an integer indicating the mouse button that was pressed, where 0 = none, 1 = left, 2 = wheel or middle, and 3 = right.

evt.which

Identify the general structure for accessing each value from an array using a for loop.

for (var i = 0; i < array.length; i++) { commands involving array[i]}

Which of the following expressions can be used to reference a form element using its name or id attribute?

form.elements.ename;

A(n) _____ is a collection of commands that performs an action or returns a value.

function

Which of the following syntax is used for a function to return a value?

function function_name(parameters){ commands return value;}

In many web forms, important data is stored within _____ so that the data is available to programmers but removed from the user's control.

hidden fields

What is the output of the following code? for (var i = 0; i <= 360; i+=60)

i = 0, 60, 120, 180, 240, 360

What is the output of the following code? for(var i = 5; i > 0; i--)

i = 5, 4, 3, 2, 1

Identify the syntax that determines how a new item is inserted into a nested list.

if (headLevel === prevLevel) { // Append the list item to the current list } else if (headLevel > prevLevel) { // Start a new nested list } else { // Append the entry to a higher list }

Identify the input field property or method that can be used to remove the focus from the input box.

input.blur()

Identify the input field property or method that can be used to return the current value displayed in the input box.

input.value

Which of the following syntaxes displays a dialog box, causing the user to enter input text?

prompt(text[,defaultInput])

Identify the sequence of the occurrence of events when a user types a keyboard key.

keydown,keypress,keyup

Using the _____, you can direct the browser to retrieve specific information about the URL, to reload the current page, or to load an entirely new page.

location object

Identify the method associated with browser locations that can find the protocol, hostname, and port number of the URL.

location.origin

Identify an expression that defines a date object.

new Date("month day, year hrs:mins:secs");

Which of the following methods affixes the new node as a child of a specified node?

node.appendChild(new)

Identify the property that describes a collection of all of the element nodes contained within node.

node.children

Which of the following properties returns the Boolean value true when an element contains an attribute?

node.hasAttribute

Which of the following methods includes or embeds a new node directly ahead of a child node?

node.insertBefore(new, child)

Identify the value of the node.nodeValue property for the element node.

null

Identify the syntax to add an event listener to an object.

object.addEventListener(event, function [, capture = false]);

Identify an expression used to apply a method to an object. Object.name(method) object.object(method) object.method(values) Object.name(values)

object.method(values)

Identify the syntax to remove an event listener.

object.removeEventListener(event, function [, capture = false]);

Which of the following is the correct syntax for a command in JavaScript to apply inline styles using the following style attribute?

object.style.property = "value";

The _____ event handler is applied to a page when it is about to be unloaded by the browser.

onbeforeunload

For options buttons and check boxes, use the _____ event handler in response to the user clicking those elements.

onclick

The _____ property returns a Boolean value indicating whether the option button, option, is currently checked by a user.

option.checked

Radio buttons are grouped by a common field name placed within the _____ array.

options[idref]

Identify the options object collection in which the selection list options are organized.

select.options[idref]

_____ is a selection list property that returns the number of options displayed in the selection list.

select.size

Identify a method that repeatedly runs commands at specified time breaks in a function created.

setInterval("command", interval)

Which of these properties describes the URL of a styleSheet file?

sheet.href

The _____ property describes the embed or link element node that creates a style sheet.

sheet.ownerNode

For array data that should be treated as a queue, the _____ method is used, which is similar to the pop() method except that it removes the first array item and not the last.

shift()

A(n) _____ is any group of characters enclosed within either double or single quotation marks in JavaScript.

text string

The _____ property should be used only when no markup tags are involved.

textContent

Identify a method that inserts new items at the front of an array.

unshift()

Identify the toLocaleString() method that gives you more control while formatting numeric values.

value.toLocaleString(locale, {options})

Identify a command that uses the dateDiv variable to refer the page element with ID dateNow.

var dateDiv = document.getElementById("dateNow");

Identify the expression in which the initial value of the day variable will be set to match the first day of the calendar month.

var day = new Date(calDate.getFullYear(), calDate.getMonth(), 1);

Identify the correct syntax to move up a node tree.

var levelUp = prevLevel - headLevel; for (var i = 1; i <= levelUp; i++) { outlineList = outlineList.parentNode.parentNode; }

Which of the following codes inserts text for each item as a hyperlink?

var linkElem = document.createElement("a"); linkElem.innerHTML = n.innerHTML; linkElem.setAttribute("href", "#" + n.id);

Which of the following code creates a list item element by using the setAttribute ()method to set the ID value of the list item to the text string "list1"?

var listElem = document.createElement("li"); listElem.setAttribute("id","list1");

A(n) _____ is a named item in a program that stores a data value, such as a number or text string, or an object, such as a part of the web browser or browser window.

variable

Identify a command that displays a dialog box containing the message "Hello World!". window.Alert("Hello World!"); Window.alert("Hello World!"); window.alert("Hello World!"); Window.Alert("Hello World!");

window.alert("Hello World!");

What is the output of the following code? var x = ["a", "b", "c"]; x.push("d", "e"); x.pop(); x.pop();

x = ["a", "b", "c"]


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

Chapter 16: Trauma, Stressor-Related, and Dissociative Disorders

View Set

Policy Loan and Withdrawal Provisions

View Set

ZOO 3731 Human Anatomy Final Quizlet

View Set

FIN 5352 Lecture 5 Chapter 8 Section 15.2 - 15.3 - Dr. Chittenden

View Set

BUS 100 EXAM 2 PRE LECTURE QUIZES

View Set

Mosby CT Review Exam: Image Production

View Set

Section 1.1: Why Study Economics? (Ver. 2)

View Set

Security, responsibility and trust in Azure

View Set