N341 Chapters

¡Supera tus tareas y exámenes ahora con Quizwiz!

strict not equal to

!==

Which of the following is a truthy value?

"false" 167

logical and

The && operator used to form a compound Boolean expression

var myPhone = new Object();

empty object

Which of the following is NOT a type of JavaScript operator?

sign operator

The Document Object Model (DOM) _____. Correct Answer

specifies how the browser should make a model of the html page Correct Answer is a tree-like structure specifies how JavaScript can change the html page

Check each line of code that correctly sets strMessage to a string value:

strMessage = 'Sally said, "hello!" '; strMessage = "Sally said, \"hello!\" ";

var strMessage = 'Hello World';

strMessage can use the built-in properties and methods of the String object. r strMessage.length returns the length of the message - which is 11

The break keyword tells the JavaScript interpreter _____ .

that is has finished with a switch statement to go to the first line of code that appears after a loop or switch statement

A switch statement works like a series of if statements. The difference is that the switch statement performs more quickly.

true

A unary operator returns a result using just one operand.

true

After a DOM query, if your script needs to use the result more than once, it is a good idea to store the location of the element(s) in a variable. This is known as caching the selection.

true

Event listeners are not supported in some older browsers, so it is necessary to provide fallback code if support for those browsers is necessary. Correct Answer

true

Multi-line comments start with /* and end with */. These comments can span many lines and are often used to describe how the script works.

true

he Math object _____.

Correct Answer is used with the name of the Math object followed by the needed property or method. For example, numTwo = Math.sqrt(4); Correct Answer has a method that generates a random number Correct Answer is a global object

The keyword this ______?

Correct Answer refers to the window object when used in a global context Correct Answer usually refers to the object in which the function operates. Correct Answer has a value that changes in different situations.

do while

Correct Answercode needs to run at least once

HTML attribute; Old technology - DO NOT USE

HTML Event Handler

There are two very different approaches to changing content on a DOM tree: [ Select ] property and DOM manipulation. [ Select ] easily targets individual nodes in the DOM tree, whereas [ Select ] is better suited to updating entire fragments.

INNERHTML DOM manipulation

var intA = 1; // first operand in the condition var intB = 2; // second operand in the condition var intC = 3; // third operand in the condition if (!(intA < intB)) { doStuff(); } // end if

In the example above, doStuff() will _____. never be called

In JavaScript, what does the operator ++ do?

It adds one to the current number.

In JavaScript, what does the operator + do?

It adds two numbers. It concatenates two strings.

Choose 3 correct statements for type coercion? Correct Answer

It creates a need for using strict equality operators Correct Answer It can lead to errors. Correct Answer It can lead to unexpected values in your code

Which two of the following steps must be completed to add an element to the page using DOM manipulation?

Add the element to the DOM - appendChild() Correct Answer Create the element - createElement()

events occur when the user interacts with the browser's UI rather than the web page.

User Interface (UI)

Which of the following are focus & blur events?

blur focusout Correct Answer focusin Correct Answer focus

When evaluating a condition with a comparison operator, the result will be a _____.

boolean

Properties and methods of an object are accessed using _____.

dot notation

document.write()

easy way for beginners to learn to add content to a page using this technique after the page has loaded can cause it to overwrite the entire page

If an HTML page contained a 8x8 table of nodes, creating an event handler for each of the 64 nodes could slow down the page. Fortunately, event flow allows JavaScript to listen for an event on a parent element. A single listener can be created on the parent element, and the event object's target property can be used to determine which node of the table was clicked. The process of creating a single listener on a parent event is called _____.

event delegation

All JavaScript element selection methods are supported equally well in every major browser.

false

An array can be a list of numbers or strings, but not a list of objects.

false

Writing comments inside a script is a way to explain what the code is doing. The JavaScript interpreter carefully reads each comment to get detailed information.

false

A series of statements that have been grouped together to form a specific task is called _____.

ffunction

A function that appears where the interpreter expects to see an expression is called a _____

function expression

TEXTcONTENT

gets or sets only text from the containing element

innerHTML

gets or sets text & markup but has security risks

A variable that is declared outside a function can be used anywhere in the script. It is called a _____ variable and has _____ scope.

global globa

When an event has occurred, it is said to [ Select ] . Events are said to [ Select ] a function or script. When it is indicated which event will cause a response on a selected node, it is said to [ Select ] an event to a DOM node.

have fired or have been raised trigger bind

Objects _____.

have functions that become known as methods Correct Answer group together a set of variables and functions Correct Answer create a model of something you would recognize from the real world Correct Answer have variables that become known as properties

Within an object, the value of a property can be a _____.

Correct Answer Array Correct Answer Number Correct Answer Boolean Correct Answer String Correct Answer another object

To use the built-in Date object in JavaScript, it is necessary to create an instance of the Date object using the constructor method.

Correct Answer True

Using global variables can lead to errors and slowly performing scripts because _____.

Correct Answer global variables can have naming collisions with other scripts Correct Answer global variables use more memory than local variables

does not work with IE8 or earlier; can attach multiple functions to an event

DOM Level 2 Event Listener

The following line of code sets a variable to a numeric value:

intQuantity = 7;

Correct Answer An array

is a list of values. It is helpful for storing a list of related items.

keyboard events

keypress, keydown, keyup input

var myPhone = {};

literal notation

To access the elements on the DOM tree, JavaScript can be used to select _____.

multiple nodes by class Correct Answer using CSS selector syntax Correct Answer an individual node by element id Correct Answer multiple nodes by tag name

events occur when the DOM structure has been changed by a script.

mutation

Three data types that JavaScript uses are

numeric string boolean

You Answered Document Object Model Correct Answer

page title, last modification date, getElementById() method

Global JavaScript Objects Correct Answe

rString, Number, Math, and Date objects

The response that a function provides when it is called is a _____.

return

The location of a variable declaration will affect where it can be used within the code. This is known as the variable's _____.

scope

Event handling involves three steps. Put these steps in the order they must appear in the code.

select element node bind an event to node specify code that is to run

Each individual instruction in a script is known as a statement. Statements should end in a ____. This allows both the human and the computer to understand the code.

semicolon

When an event occurs, the event object tells _____.

the type of event that was fired Correct Answer information about the event information about the element that triggered the event

strong support in all major browsers; can only attach a single function to an event

traditional DOM event handler

A DOM query can return either one element or a collection of nodes.

true

Once an element node is selected, it is possible to select other nodes related to it. This is called traversing the DOM. New elements can be selected based on their relationship as a parent, sibling, or child of the originally selected element.

true

Once an element node or group of nodes is selected, the attributes, the child elements, and the text content can be changed.

true

Operators and expressions allow programmers to create a single value from one or more values.

true

Single-line comments begin with two forward slash characters. They are usually used to provide short descriptions of what the code is doing.

true

Some browsers treat whitespace between elements as a text node. So, a DOM query can return different elements in different browsers.

true

The preventDefault() method of the event object changes the default behavior of an element. This can be used to keep the user on the page after clicking on a link.

true

Two essential steps to using variables are to declare them and to assign them a value.

true

In JavaScript, the _____ keyword is used to declare variables.

var

Computers use _____ to store data for use in computations or for later reference.

variables

Browser Object Model You Answered

window location, scrolling distance, and alert() method

logical or

||

strict equal to

===

main types of DOM nodes?

The Document Node Correct Answer Element Nodes Correct Answer Attribute Nodes Correct Answer Text Nodes

The following rules apply when giving a variable a name.

The name must not contain a dash or a period. Correct Answer The name must not start with a number. Correct Answer All variables are case sensitive

var intA = 1; // first operand in the condition var intB = 2; // second operand in the condition var intC = 3; // third operand in the condition if (place condition here) { doStuff(); } // end if

Which expression will NOT allow the function doStuff() to be called? intA>=int B

The following line of code sets a variable to a Boolean value:

blnIsBlue = true;

falsy value

a variable with no value assigned to it

Cross-Site Scripting Attacks (XSS) involve an attacker placing malicious code into a site. Using the innerHTML property to allow user input is one way to enable these attacks. XSS can allow an attacker to _____. Correct Answer

access the site's cookies Correct Answer post unwanted content Correct Answer spread malicious code Correct Answer make purchases with the user's account Correct Answer access the user's login information Correct Answer access form data

strColors = ['red', 'white', 'blue']; Correct Answer

an array literal

To organize your data, you can either use an array or use an object to group a set of related values. If the order of the items is important, it is better to use an _____.

array

var strColors = new Array('red', 'white', 'blue');

array constructor

If different parts of a script need to perform the same task, writing a function will _____.

avoid unnecessarily repetitive code Correct Answer keep the code shorter Correct Answer make the script easier to read

dom mainpulation

best technique to use when changing one element that has many siblings if many changes are needed, it needs more code and is slower than other methods does not affect event handlers

element.innerHTML

can be used to add lots of new markup using less code than other options simple way to remove all content from one element (by assigning it a blank string)

When creating lots of objects with similar functionality, it is good to use _____.

constructor notation

var myPhone = new Phone(ꞌmobileꞌ, ꞌ3175551212ꞌ, 200);

constructor notation

Two keywords that are often used with loops are:

continue break

Sections of statements called code blocks are surrounded by _____. This creates a group of statements and helps to make scripts more readable.

curly braces

Which loop has the statements in the code block before the condition?

do while

var intA = 1; // first operand in the condition var intB = 2; // second operand in the condition var intC = 3; // third operand in the condition var intD = 4; // fourth operand in the condition if ( (intA < intB) || (intC > intD) ) { doStuff(); } // end if else { doDifferentStuff(); } //end else

doStuff() is always called. Correct Answer the condition (intC > intD) is not checked


Conjuntos de estudio relacionados

Repaso para el examen de inglés

View Set

A&P Endocrine System Multiple Choice

View Set

BIOS240 Water and Salt Physiology

View Set

2 - State Exam Simulator - 150 Practice Exam Questions

View Set