CSCI 215 Final Exam Study

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Identify a true statement about a function in JavaScript.

A function can be stored as a variable.

Identify the description for the \b character type.

A word boundary

What is the type of value for favorite?

Boolean

Michelle has defined a custom object by creating an object literal. She wants to access the properties of the custom object. Which of the following can help Michelle to access the properties of the custom object?

Dot operator

_________ are actions initiated by a user or a browser, such as clicking on an object on a form or closing a webpage.

Events

What pattern would match the string "Regular Expression"?

Exp

A limitation of an event handler is that only one function can be applied to it at a time. True or False

False

Each parent node can contain only one child node. True or False

False

Good coding practice dictates that global variables must be used as much as possible in a program. True or False

False

Index values start with 1 so that the initial item in an array has an index value of 1, the second item has an index value of 2, and so on.​ True or False

False

Instantiating an object from a constructor function results in efficient use of memory and resources. True or False

False

JSON is only useful for JavaScript programs. True or False

False

JSON is the only format for communicating between browser and server.

False

Named functions are more concise and easier to manage than anonymous functions. True or False

False

The mouseout event indicates the movement of a mouse pointer onto an element. True or False

False

The node.previousSibling expression describes the sibling after node. True or False

False

The onclick event handler recognizes the propagation of events through the capture and bubbling phases. True or False

False

To create a custom object as an object literal, you apply the create() method. True or False

False

var re = /regex/; var x = re.test("regular expression"); True or False

False

​A variable requires an initial value to be defined. True or False

False

​If no value is assigned to a Boolean variable, it is interpreted as having a value of true. True or False

False

​JavaScript is a procedural language that needs a compiler to translate the code into machine language. True or False

False

​The Math.round(x) method rounds the value of x down to the next lowest integer. True or False

False

​The async attribute stalls script processing until after the page has been completely parsed and loaded. True or False

False

​The break statement runs a command or a command block only if the conditional expression returns the value true; it does nothing if the condition is false. True or False

False

​The first character of a variable must be a numeral or an underscore character ( _ ). True or False

False

​The getDate() method in a calendar app returns an integer ranging from 0 (Sunday) to 6 (Saturday). True or False

False

​The slice() method reverses the order of items in an array, making the last items first and the first items last. True or False

False

​The value of the length property can be reduced without removing items from an array. True or False

False

​The while statement is used to exit a program loop before the stopping condition is met. True or False

False

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 significance of this keyword in the following constructor function. function objClass(parameters) { this.prop1 = value1; this.prop2 = value2; ... this.method1 = function1; this.method2 = function2; ... }

It refers to any object instance of the object class.

Identify the description of the option.selected property.

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

​_____ is the programming language for client-side programs.

JavaScript

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

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

Both HTML tags and text content can be returned by the innerHTML property. True or False

True

For options buttons and check boxes, you can use the onclick event handler in response to the user clicking those elements. True or False

True

Function operators are more flexible than function declarations, allowing a function to be placed anywhere a variable can be placed. True or False

True

JSON is easy for humans to read and write. True or False

True

JavaScript is an object-based programming language that involves working with the properties and methods associated with objects. True or False

True

One object can be nested within another. True or False

True

The commands that a browser runs in response to an event is a script. True or False

True

The contents of an HTML file are arranged in a hierarchical structure, starting from the root html element itself and moving down to the text strings contained within individual page elements. True or False

True

The dblclick event indicates that the mouse button has been double-clicked. True or False

True

The element.value = value; expression is applied to set the value of an input control. True or False

True

The event model describes how events and objects interact within a web page and a web browser. True or False

True

The event object contains properties and methods associated with an event.

True

The evt.pageY property returns the vertical coordinate (in pixels) of the mouse pointer relative to the document. True or False

True

The evt.target returns the object in which the event was initiated. True or False

True

The node.childNodes describes a collection of all of the nodes that are direct children of node. True or False

True

The node.firstElementChild property is applicable only to element nodes. True or False

True

The regex /run/ matches the string "pruning". True or False

True

To create object classes, you should apply a function known as an object constructor that defines the properties and methods associated with the object type. True or False

True

What value is x? var re = /c\/1/; var x = re.test("abc/123"); True or False

True

You can control the number of digits displayed by the browser using the toFixed() method. True or False

True

You can determine whether an object has the property, prop, using the hasOwnProperty(prop) method. True or False

True

for...in loops do not follow a specific order because properties can be listed and read out in any order. True or False

True

​A calendar that is created as a web table can have class and ID designations to make it easy for page developers to assign different styles to different parts of the calendar. True or False

True

​An object can be modified by changing its properties or by applying a method. True or False

True

​By default, items are placed in an array either in the order in which they are defined or explicitly by index number. True or False

True

​Increasing the value of the length property adds more items to an array, but the items have null values until they are defined. True or False

True

​JavaScript is case sensitive. True or False

True

​JavaScript supports logical operators that connect several expressions. True or False

True

​JavaScript supports methods to change the date stored within a Date object. True or False

True

​Parameters are treated as variables within a function. True or False

True

​Server-side and client-side programming are the two main types of web-based programming. True or False

True

​The appearance of any form element can be changed by modifying style sheets instead of the JavaScript code. True or False

True

​The do/while loop is generally used when the program loop should run at least once before testing for the stopping condition. True or False

True

​The isNaN(value) function returns a Boolean value of true if the value is not numeric. True or False

True

​The script element can be placed anywhere within the HTML document. True or False

True

The regular expression pattern for a character class is _____.

[chars]

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

\S

To create a negative character class that matches any character not in the class, preface the list of characters with the _____ symbol.

^

Fill in the blank so the regex matches the description. Match anything except a vowel (a, e, i, o, u). List characters in the regex alphabetically. /[___]/

^aeiou

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")

​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

What string does NOT match the regex /cat|bat|mat/?

at

In the _________ phase, the event propagates up the object hierarchy back to the root element (browser window) where the propagation stops.

bubbling

In the _____ phase, the event moves down the object hierarchy, starting from the root element and moving inward until it reaches the object that initiated the event.

capture

JavaScript is used as a programming tool for: ​

creating interactive web forms and animated graphics

​The _____ attribute can be applied to the script element to ensure that an object can be referenced within a JavaScript program that runs only after the page has completed loading.

defer

Identify the general syntax of the do/while loop.

do { commands } while (continue);

​Document objects are organized in hierarchical structures called the _________.

document object model (DOM), DOM

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

document.createAttribute(age)

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

document.createElement(elm)

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

document.forms[idref]

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)

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) { e.preventDefault(); }

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

document.querySelectorAll(selector)

Thomas wants to create a custom object using the new operator. He applies the following commands: var objName = new Object(); object.property = value; object.method = function() { commands }; The new Object() statement is equivalent to a(n) _____.

empty object literal

A(n) _________ is a property that controls how an object will respond to an event, waiting until the event occurs and then responding by running a function or a command block to execute an action.

event handler

A(n) _________ observes events as they propagate through the capture, target, and bubble phases, allowing the script to respond to an event within any phase.

event listner

Which of the following mouse event properties returns the vertical coordinate (in pixels) of the mouse pointer relative to the browser window?

evt.clientY

​Identify the general structure of a for loop.

for (start;continue;update) { commands }

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] }

Identify the syntax for looping through a collection of child nodes using the counter variable method.

for (var i = 0; i < node.childNodes.length; i++) { commands }

A _____ does not follow a specific order because properties can be listed and read out in any order.

for...in loop

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

function function_name(parameters){ commands return value;}

What string does NOT match the regex /grea*t/?

grat

What string does NOT match the regex /w+hy/?

hy

​Identify the structure of an if statement

if (condition) { commands }

​When writing an HTML code, changing the value of the _________ property overwrites whatever content is currently contained within the selected object.

innerHTML

During a mouse action, events cannot be fired more than once.

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

In an object literal, each _____ pair contains a property and property value associated with the object.

name:value

Kenneth wants to create a custom object for a specific programming task. He has defined the custom object by creating it as an object literal. Kenneth should store the properties of the object within a comma-separated list of _____ pairs enclosed within a set of curly braces.

name:value

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

The _____ method discards the old node from node.

node.removeChild(old)

Identify the method that eliminates the old node and exchanges it with a new node.

node.replaceChild(new, old)

​A(n) _________ is an entity within the browser or web page that has properties that define it and methods that can be acted upon it.

object

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? <element style = "property:value">...

object.style.property = "value";

Which of the following notations is used to write object properties?

object["property"]

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

option.checked

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

prompt(text[,defaultInput])

​This method appends an array with new items.

push(values)

A(n) _________ is a text string that defines a character pattern.

regular expression

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

select.size

​A command that indicates an action for the browser to take should end with a _____.

semicolon

Which of the following methods can be used to reference a character at the index i of the string?

string.charAt(i)

Which of the following methods can be used to extract longer text strings?

string.slice(start [,end])

The _________ phase includes the event that has reached the objective of the event object and no longer moves down the object hierarchy.

target

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");

Edward wants to use object-based programming to create objects that belong to a specific type or class with shared properties and methods. Once the constructor function for the object class is defined, instances of the object are created with the _____ command.

var objInstance = new objClass(parameters);

Which of the following commands is used to create a custom object using the new operator?

var objName = new Object(); objName.property = value; objName.method = function() { commands };

Identify the correct syntax to add methods to a custom object.

var objName = { method: function() { commands } }

Identify the name:value pair that includes a function name and its commands, which is used to add methods to a custom object.

var objName = { method: function() { commands } }

​Identify the syntax of the while loop.

while (continue) { commands }

JSON.stringify(_____)returns the string '{"a":true,"b":[ ],"c":null}'.

{a:true,b:[ ],c:null}

Which of the following should be appended to a character to repeat it n times?

{n}

In a regular expression, you can define two possible patterns for the same text string by joining different patterns using the _____ character. 13

|

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

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

Which of the following is created by a programmer for use in an application.

​Customized objects

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

​Debugging

​It is indicated by the - - symbol, which reduces the operand's value by 1.

​Decrement operator

​Which of the following can be referenced only after the browser has finished parsing the page content?

​Document objects

​Identify a shortcut key on the keyboard to open the debugging tools.

​F12

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

​Math.ceil(x)

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

​array.length

​This method converts the contents of an array to a text sequence with the array values in a comma-separated list.

​array.toString()

​Identify the expression used to reference array values.

​array[i]

​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

​This method links all items in the array into a single text string.

​join(separator)

​JavaScript comments can be entered on single or multiple lines.

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

Robin maintains a web page for updating the metro timings in the city. He would like the website to display the present day's schedule. To do this, Robin writes a code that includes an object to retrieve the day of the week and then loads the appropriate data into the page. ​ ​Identify an expression that Robin must use to define the current date on the web page.

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

​Identify an expression used to apply a method to an object.

​object.method(values)

​Identify a function that extracts the first numeric value from the text string.

​parseFloat(string)

​It extracts the first integer value from a sequence of characters.

​parseInt(string)

​This method removes the last item from an array.

​pop()

​This method inverts the order of items in an array.

​reverse()

​JavaScript code is attached to an HTML file using the _____ element.

​script

​Identify a method that is used to create a subarray.

​slice()

​This method rearranges array items in alphabetical order.

​sort()

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

​It returns a text string displaying value to n decimal places.

​value.toFixed(n)

​It returns a text string displaying value to n significant digits either to the left or to the right of the decimal point.

​value.toPrecision(n)

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

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

​It is a command to create a dialog box containing a message.

​window.alert(" ");

​Identify a command that displays a dialog box containing the message "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"]

JSON.parse(_____) produces an array of three values: 1, 7, and 19.

'[1,7,19]'

Fill in the blank so the regex matches the description. Match only the digits 0 through 5. /[___]/

(0-5, 012345)

Fill in the blank so the regex matches the description. Match only the letters a through f. /[___]/ ________

(a-f, abcdef)

Identify the syntax used to group character symbols so they can be treated as a single unit.

(pattern)

Match the regex to a string the regex matches. break1 9

/1\s\d/

good2 7

/1\s\d/

156good

/1\w+/

Match the regex to a string the regex matches. 123break

/1\w+/

934good

/9\d+/

Match the regex to a string the regex matches. ()break

/9\d+/

Match the regex to a string the regex matches. 923break

/9\d+/

()good

/\W\W\D/

William is exploring the syntax of regular expressions. He learns that in the regular expression language, a word refers to any string of symbols consisting solely of word characters. He also learns that word boundaries are indicated by the \b symbol. He wants to use a pattern that matches any word that starts with the characters "great" such as "greater", "greatness", or "greatest" Which of the following patterns should William use?

/\bgreat/

0.good

/\d\./

Match the regex to a string (the regex matches.)0.good

/\d\./

Match the regex to a string the regex matches. 0.break

/\d\./

8?*good

/\d\S\?/

Match the regex to a string the regex matches. 5!?break

/\d\S\?/

What regex matches the string "sleep like a baby"?

/^sleep/

What regex matches the string "that's easy"?

/b?sy$/

What regex matches the string "boom"?

/ba?oom/

What regex matches the string "breaeak"?

/br(ea)+k/

Regular expressions have the general form denoted as _____.

/pattern/

William is exploring the syntax of regular expressions. He learns that in the regular expression language, a word refers to any string of symbols consisting solely of word characters. He also learns that word boundaries are indicated by the \b symbol. He wants to use a pattern that matches any word that starts with the characters "great" such as "greater", "greatness", or "greatest" Which of the following patterns should William use to match any word that ends with "ust" such as "dust", "trust", or "must"?

/ust\b/

What regex matches the string "what?"?

/what\?$/

How many times does the regex /moo/g find a match in "Moo the cow mooed at the moon."

2

How many times does the regex /moo/gi find a match in "Moo the cow mooed at the moon."

3

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

Robin maintains a web page for updating the metro timings in the city. He would like the website to display the present day's schedule. To do this, Robin writes a code that includes an object to retrieve the day of the week and then loads the appropriate data into the page. ​ Robin includes an expression to the code, var thisDay = new Date("May 23, 2018 14:35:05"); ​ Identify the value for the month that will be displayed on the web page by using thisDay.getMonth() method.

4

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

<element onevent = "script">

William has created a page view style sheet and saved it in a file named esd.css. Which of the following tags should William add to the document head to apply the style sheet?

<link href="esd.css" rel="stylesheet" />

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

===

​In an array literal, the array values are a space-separated list within a set of curly brackets. True or False

False

​This method joins the array to two or more arrays, creating a single array containing the items from all the arrays.

​concat(array1, array2,...)

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

​do/while

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

​element.innerHTML

​It returns the HTML code within element as well as the HTML code of element itself.

​element.outerHTML

​It returns the text within element disregarding any HTML tags.

​element.textContent

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

​function

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

The regex /run/ matches the string "pr uning". True or False

False


Set pelajaran terkait

Chapter 1: Financial Accounting and Accounting Standards: Questions

View Set

H-01:P2 State intervention goals in observable & measureable terms

View Set

Med Term Ch.2-3 Test (ch.2 multiple choice)

View Set

IT 214 Full Practice Midterm Exam 2

View Set