Intro to JS Final Exam

Ace your homework & exams now with Quizwiz!

If you have a variable named x and it contains the string "Hello", what would be the return value of x.length in JavaScript code?

5 (L5 Q3)

If a variable named x contains Hello World, what would x.indexOf("W") return?

6 (L7 Q3)

Which of the following is a valid way to express a number in JavaScript?

9876.56 (L4 Q2)

If you de ne an array using var artists=["Bach","Beethoven","Mozart"];, what value would be assigned to artists[1]?

Beethoven (L8 Q1)

Which of the following best describes the purpose of the JavaScript .className property?

Gets or sets the CSS style class that's assigned to an element. (L9 Q5)

Which are the recommended audio types for HTML5 audio?

MP3 and OGG. (L6 Q1)

Which company is usually credited with inventing JavaScript (or at least getting the ball rolling with a language named LiveScript?)

Netscape. (L1 Q1)

What are the MIT and GPL licenses commonly associated with?

Open-source software that you are free to use in your own work. (L12 Q4)

$("selector").event(function(){ code to execute; });

What is the syntax for jQuery CSS selectors?

What do people who share jQuery plugins tend to assume about you, a person who'll be using the code in your own sites?

You understand HTML, CSS, JavaScript, and jQuery well enough that you can figure things out on your own. (L12 Q5)

Which object and method would you use to have JavaScript write tags or content directly into the page?

document.write() (L3 Q4)

jquery event object properties?

event.property .type - type of event(eg.click) .target - element the called the event .data - data passed to bind() .pageX,pageY - position of mose to doc .result - value returned by hand .timestamp - time when occurred (ms)

Which of the following best describes jQuery decision-making?

jQuery uses the same syntax as JavaScript for if . . . then decisions. (L11 Q5)

what jQuery function is used to load another script file

jQuery.getScript() Load a JavaScript file from the server using a GET HTTP request, then execute it.

Which of the following correctly creates a variable named fname and assigns the value Babs to that variable?

var fname = "Babs"; (L3 Q5)

Which of the following stores a Boolean value in a variable named isvalid?

var isvalid=false (L4 Q3)

Which of the following stores a string in a variable named x?

var x = "[email protected]" (L4 Q1)

What is the correct syntax for making an element slide into and out of view quickly?

(.slideToggle("fast") L11 Q2)

Which JavaScript property determines if the user's Web browser can play a particular type of sound file?

.canPlayType() (L6 Q2)

Microsoft Azure/Google CDN

A cloud platform that provides platform as a service (cloud network) and infrastructure as a service solution to enterprises (high-level APIs)

What is the name of the standards organization that de nes and maintains the JavaScript language?

ECMA International. (L1 Q2)

If a function named myfunc() contains the line var x=10; what would be the scope of that x variable?

It's local to myfunc(), exists only while myfunc() is executing, and it's inaccessible to other JavaScript functions on the page. (L7 Q2)

What JQuery version must you learn to cover IE versions 6, 7, and 8?

JQuery Version 1 as Version 2 does not include backwards compatibility with IE versions 6, 7, and 8.

Let the entire page load before trying to execute any jQuery code.

Just like window.onload in JS, we use // Just like window.onload in JS, we use $(document).ready(function() { // jQuery code to execute after page load }); // .ready function includes closing parenthesis AFTER ending brace to close out .ready function // allows JQuery to load with elements immediately

What does it mean if a jQuery plugin claims to be swipeable?

People with touchscreens can control it by swiping their finger across the screen. (L12 Q3)

Which JavaScript construct is often used in place of a long series of if . . . else statements when there are many options to consider?

Switch statement. (L8 Q5)

What is the purpose of the parseInt() function?

To convert a string to an integer. (L7 Q5)

Which feature of JavaScript allows you to organize code into routines that can be called by name from event handlers in tags?

Functions. (L2 Q5)

What character is used throughout JavaScript code to call code in the jQuery library?

$ (L10 Q2)

Which of the following shows properly nested quotation marks?

(L2 Q4)

What is the correct spelling of the document object METHOD that allows you to reference an element on the page by its ID name (be sure to pay attention to case-sensitivity)?

.getElementById() (L3 Q2)

If variable personname contains the string Joan Doe, what would the expression personname.substr(5,3) return?

.substr (x, y) x=starting point , y= length Doe (L7 Q4)

If your JavaScript code contains two variables named str1 and str2, and if both of those variables contain strings (text), not numbers, what would the expression str1+str2 return?

A new string consisting of str1 and str2 joined together. (L5 Q4)

What is the definition of the term millisecond?

A thousandth of a second. (L9 Q3)

$("button").click(function(){ code to execute; });

In fact, having the option to write code that applies to multiple elements on the page is one of jQuery's best features. In that generic $(selector).event syntax, you can put just about any CSS selector in place of selector to apply the code to any number of elements on a page, just as you can use CSS selectors to apply CSS styles to any number of elements on a page. So let's explore those selectors in a bit more depth.

Which best describes the action required for the result jQuery code that has the selector and event handler $("img").click?

The user clicks any image on the page. (L10 Q5)

What's the purpose of adding site: and a domain name to a Google or Bing search?

To limit the search results to one website (rather than the entire Web). (L5 Q1)

jQuery

a collection of prewritten JavaScript code that lets us easily create interactive effects on your site Versions with higher numbers are newer than versions with smaller numbers, although there is one important distinction between versions 1 and 2. Versions that start with 1 continue to provide support for Internet Explorer versions 6, 7, and 8. Versions starting with 2 offer all the same tools and capabilities that versions starting with a 1 offer. But version 2 does not include code that allows all jQuery features to work in those older Internet Explorer versions 6, 7, and 8. You'll have to decide for yourself which one you want to use.

What would be the correct syntax for stopping a timer named myTimer?

clearInterval(myTimer) (L9 Q4)

Which line of JavaScript code below could you use to make an element named goober invisible on a page?

goober.style.display="none" (L6 Q5)

Which DOM object includes properties for determining the height and width of the user's screen in pixels?

screen (L3 Q1)

Which object and property return the width of the user's screen as a whole?

screen.width (L3 Q3)

What's the correct syntax for calling a function named changesize() repeatedly every two seconds?

setInterval("changesize()", 2000) (L9 Q2)

layer 4 and layer 7 DDoS attacks

targets TRANSPORT layer or APPLICATION layer processes

Resources

"Get as familiar as you can with your code editor, zoom, slack, and even git ASAP. Learn the tools so you can learn the skills." Mychal Hall

If you executed var lookfor = document.getElementById("txtlookfor").value;, what would be the result?

It creates a variable named lookfor and stores in it whatever the user typed into a textbox named txtlookfor. (L5 Q2)

What's the meaning of the jQuery selector $('.wookie p')

(All paragraphs inside an element whose opening tag includes class="wookie". L11 Q3)

Which is the shortest, simplest pair of tags you can use in HTML5 to mark the beginning and end of a block of JavaScript code?

(L1 Q4)

What does the jQuery toggleClass() method do?

(Switch between different CSS classes for styling an element. L11 Q1)

What JavaScript method allows you to specify a sound file for an HTML audio object to play?

.setAttribute() (L6 Q3)

If you create a CSS style class to display one background image and then create a second CSS style class to display a di erent background image, which jQuery method would allow you to switch between the two di erent background images?

.toggleClass() (L11 Q4)

Which JavaScript property allows you to control the volume of sound through JavaScript?

.volume() (L6 Q4)

If you start a loop with for (var i = 10; i <= 100; i += 10), how many times will that loop repeat?

10 (L8 Q3)

Which of the following would be the correct way to multiply 2 by 5 (two times ve) in JavaScript?

2 * 5 (L4 Q4)

If you create a short array using the syntax var big3=["Chevy","Ford","Chrysler"];, what would the expression big3.length return after doing so?

3 (L8 Q2)

Application Programming Interface (API)

A block of code in the operating system that software applications need to interact with.

Content Development Network

A content delivery network (CDN) refers to a geographically distributed group of servers which work together to provide fast delivery of Internet content. A CDN allows for the quick transfer of assets needed for loading Internet content including HTML pages, javascript files, stylesheets, images, and videos. The popularity of CDN services continues to grow, and today the majority of web traffic is served through CDNs, including traffic from major sites like Facebook, Netflix, and Amazon.

DDoS Attack

Distributed Denial of Service Attack. Typically a virus installed on many computers (thousands) activate at the same time and flood a target with traffic to the point the server becomes overwhelmed. A distributed denial-of-service (DDoS) attack is a malicious attempt to disrupt normal traffic of a targeted server, service or network by overwhelming the target or its surrounding infrastructure with a flood of Internet traffic. There are a few important differences between layer 3 DDoS attacks and attacks at the higher layers: Layer 3 attacks target the network layer, not transport layer or application layer processes (as layer 4 and layer 7 DDoS attacks do) Layer 3 attacks do not have to open a TCP connection with the target first Layer 3 attacks do not target a specific port

What does $(document).ready do in jQuery?

Ensures that the page is loaded and ready to go before any jQuery code is executed. read as: $document.ready function (L10 Q3)

In the JavaScript code setTimeout("alert('Boo!')", 5000);, what does the 5000 represent?

Five seconds of time. (L9 Q1)

What is a widely used online version-control system and code repository for all kinds of software (not just jQuery plugins)?

GitHub. (L12 Q2)

What are the three client-side languages that all Web browsers can execute?

HTML, CSS, JavaScript. (L1 Q3)

What is the meaning of the JavaScript ++ operator?

Increment the value by 1. (L8 Q4)

DDoS layer 3

Layer 3 attacks target the NETWORK layer, not the transport layer or application layer processes Layer 3 attacks do not have to open a TCP connection with the target first Layer 3 attacks do not target a specific port

What JQuery version are you using?

STICK with a Version 1 jQuery library for now.

What's the difference between development and production versions of JQuery files?

The development version includes indentations and line breaks while the production version does not as it is the most "min"-imally sized version.

What's the biggest challenge to using jQuery plugins?

The documentation is sparse, at best. The authors assume you can figure everything out on your own. (L12 Q1)

$("selector").effect(value);

The syntax for implementing an effect is similar to the syntax for everything else in jQuery. Here is the basic syntax:

Which of the following best describes the reason we use JavaScript event handlers?

To control when the JavaScript code is executed. (L2 Q1)

Why would you use the word selected in the <option> tag of a drop-down list control?

To make the specified option the default selection. (L5 Q5)

What's the primary difference between versions 1 and 2 of the jQuery library?

Version 1 includes support for older Internet Explorer versions 6 through 8, while version 2 does not. (L10 Q4)

JavaScript is a lightweight but incredibly powerful scripting language. Unlike many other programming languages, JavaScript doesn't need to be translated from human-readable code into a form that the browser can understand—there's no compiler step. Our scripts are sent across the wire at more or less the same time as our other assets—markup, images, and stylesheets—and interpreted on the fly. While we most frequently encounter it through our browsers, JavaScript has snuck into everything from native applications to ebooks. It's one of the most popular programming languages in the world, largely because you can find it in so many different environments. JavaScript doesn't have any strict requirements for where it runs as long as there's an interpreter to make sense of it, and open-source browsers mean opensource JavaScript interpreters—the part of the browser that parses and executes JavaScript. When developers drop these interpreters into new contexts, we end up with JavaScript-powered web servers (http://nodejs.org) and homemade robots (http://johnny-five.io). We'll be looking at JavaScript as we encounter it in the browser, but there's good news if you find yourself feeling particularly mad-scientist-y by the time we're finished: the syntax you're learning here is the same

What is JS

anonymous function

a set of related statements with no name assigned to it.

In addition to downloading the jQuery library to your computer and linking to that file within your site, what's another way to use jQuery on your site?

on a Content Development Network like Google's CDN or Microsoft's CDN. (L10 Q1)

Which of the following is the correct way to type the event handler that's triggered by clicking an element?

onclick (L2 Q3)

Which event handler would be best used to trigger JavaScript code when the mouse pointer touches an element?

onmouseover (L2 Q2)

Which of the following expressions asks the question Is price greater than or equal to 10?

price >= 10 (L4 Q5)


Related study sets

Business Driven Technology - Chapter 2 (Identifying Competitive Advantages)

View Set

Chapter 9 - Joining Data From Multiple Tables

View Set

Objective E: El Nino, La Nina sets

View Set

Combo with CA LIFE STATE PRACTICE EXAM PT 2(FROM EXAM FX ONLINE TEST) and 1 other

View Set