JS Flashcards

1
Q
Which company is usually credited with inventing JavaScript (or at least getting the ball rolling with a language named LiveScript?)
A
Google.
B
Netscape.
C
Apple.
D
Microsoft.
A

B

Netscape.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
What is the name of the standards organization that defines and maintains the JavaScript language?
A
World Wide Web Consortium.
B
Adobe Systems Incorporated.
C
ECMA International.
D
Mozilla.
A

C

ECMA International.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
What are the three client-side languages that all Web browsers can execute?
A
HTML, CSS, JavaScript.
B
ASP.Net, PHP, Ruby on Rails.
C
Windows, Mac OS, Linux.
D
HTML, CSS, Java.
A

A

HTML, CSS, JavaScript.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
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?
A
 . . . 
B
 . . . 
C
 . . . 
D
 . . .
A

B

. . .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which characters can you use to start a single-line comment in JavaScript?
A

B

A
C
//
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following best describes the reason we use JavaScript event handlers?
A
To override JavaScript case-sensitivity.
B
To control when the JavaScript code is executed.
C
To create links to external files.
D
To control the font and color of the JavaScript code’s output.

A

B

To control when the JavaScript code is executed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
Which event handler would be best used to trigger JavaScript code when the mouse pointer touches an element?
A
onmouseover
B
onclick
C
oncontextmenu
D
ondblclick
A

A

onmouseover

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
Which of the following is the correct way to type the event handler that's triggered by clicking an element?
A
CLICK
B
onclick
C
On-Click
D
on click
A

B

onclick

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
Which of the following shows properly nested quotation marks?
A
onclick="alert('Hello")'
B
onclick='alert("Hello')"
C
onclick="alert('Hello')"
D
onclick="alert("Hello")"
A

C

onclick=”alert(‘Hello’)”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
Which feature of JavaScript allows you to organize code into routines that can be called by name from event handlers in tags?
A
Functions.
B
Pages.
C
Comments.
D
Style rules.
A

A

Functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
Which DOM object includes properties for determining the height and width of the user's screen in pixels?
A
location
B
document
C
navigator
D
screen
A

D

screen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
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)?
A
.getElementById()
B
.getElementByID()
C
.GETELEMENTBYID()
D
.GetElementByID()
A

A

.getElementById()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
Which object and property return the width of the user's screen as a whole?
A
navigator.width
B
window.width
C
document.width
D
screen.width
A

D

screen.width

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
Which object and method would you use to have JavaScript write tags or content directly into the page?
A
document.referrer
B
window.open()
C
document.write()
D
location.href
A

C

document.write()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
Which of the following correctly creates a variable named fname and assigns the value Babs to that variable?
A
VAR F NAME = Babs
B
var fname = "Babs"
C
Bab = var fname
D
Var fname as "Babs"
A
B
var fname = "Babs"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
Which of the following stores a string in a variable named x?
A
var x = true
B
var x = 18932-2802
C
var x = "somewhere@somplace.com"
D
var x = -32
A
C
var x = "somewhere@somplace.com"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q
Which of the following is a valid way to express a number in JavaScript?
A
9876.56
B
987-65-4321
C
12/31/2015
D
(800) 555-1234
A

A

9876.56

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q
Which of the following stores a Boolean value in a variable named isvalid?
A
var isvalid=87
B
var isvalid = new Date()
C
var isvalid="true"
D
var isvalid=false
A
D
var isvalid=false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q
Which of the following would be the correct way to multiply 2 by 5 (two times five) in JavaScript?
A
2 * 5
B
2 == 5
C
2 / 5
D
2 < 5
A

A

2 * 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q
Which of the following expressions asks the question Is price greater than or equal to 10?
A
price != 10
B
price == 10
C
price <= 10
D
price >= 10
A

D

price >= 10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What’s the purpose of adding site: and a domain name to a Google or Bing search?
A
To limit the search results to one website (rather than the entire Web).
B
To make the search engine add the site to its index.
C
To make the search results open in a separate tab or window.
D
To exclude the site specified by the domain name from the search results.

A

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

If you executed var lookfor = document.getElementById(“txtlookfor”).value;, what would be the result?
A
It creates a variable named lookfor and stores in it a number indicating how many characters the user typed into the textbox named lookfor.
B
It creates a variable named lookfor and stores in it whatever the user typed into a textbox named txtlookfor.
C
It shows on the screen the word lookfor and the contents of a textbox named txtlookfor.
D
It creates a variable named lookfor and stores in it the ID name of a textbox named txtlookfor.

A

B

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q
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?
A
Hello
B
A time expressed in milliseconds
C
0
D
5
A

D

5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

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
A new string consisting of str1 and str2 joined together.
B
A number that’s the sum of how many characters there are in str1 and how many characters there are in str2.
C
A new variable consisting of the two variable names stuck together as str1str2.
D
A new string with whatever letters were in str2 removed from str1.

A

A

A new string consisting of str1 and str2 joined together.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Why would you use the word selected in the tag of a drop-down list control?
A
To disable the control, making it look gray on the page and preventing the user from choosing any other option.
B
To combine multiple options into one.
C
To make the specified option the default selection.
D
To assign a value to each option.

A

C

To make the specified option the default selection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q
Which are the recommended audio types for HTML5 audio?
A
AAC and WMA.
B
MP3 and OGG.
C
JPEG and GIF.
D
WAVE and AIF.
A

B

MP3 and OGG.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q
Which JavaScript property determines if the user's Web browser can play a particular type of sound file?
A
.getMimeAttribute()
B
.canPlayType()
C
.willPlayMime()
D
.playsFileType()
A

B

.canPlayType()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q
What JavaScript method allows you to specify a sound file for an HTML audio object to play?
A
.loadFile()
B
.setAttribute()
C
.play()
D
.transferFile()
A

B

.setAttribute(

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q
Which JavaScript property allows you to control the volume of sound through JavaScript?
A
.loudness()
B
.range()
C
.volume()
D
.pause()
A

C

.volume()

30
Q
Which line of JavaScript code below could you use to make an element named goober invisible on a page?
A
goober.style.display="block"
B
goober.style.display="none"
C
goober.style.visibility="invisible"
D
goober.show=false
A

B

goober.style.display=”none”

31
Q
If you add a line of JavaScript code that reads var howmany= 10 in the head section of a page, right under the  tag, what type of variable would howmany be in terms of scope?
A
Global.
B
Universal.
C
Doomed.
D
Local.
A

A

Global.

32
Q

If a function named myfunc() contains the line var x=10; what would be the scope of that x variable?
A
It’s global in the sense that it exists as long as the page stays open in the browser. All other JavaScript functions on the page can access the function.
B
It exists everywhere in the page except inside the myfunc function.
C
It’s universal in the sense that all Web pages on the Internet can access its value until you remove the page from the Web server.
D
It’s local to myfunc(), exists only while myfunc() is executing, and it’s inaccessible to other JavaScript functions on the page.

A

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

33
Q
If a variable named x contains Hello World, what would x.indexOf("W") return?
A
6
B
orld
C
5
D
7
A

A

6

34
Q
If variable personname contains the string Joan Doe, what would the expression personname.substr(5,3) return?
A
Do
B
Doe
C
A space.
D
Joa
A

B

Doe

35
Q

What is the purpose of the parseInt() function?
A
To convert an integer to a string.
B
To convert a floating point number to a string.
C
To convert a string to an integer.
D
To convert a string to a floating point number.

A

C

To convert a string to an integer.

36
Q
If you define an array using var artists=["Bach","Beethoven","Mozart"];, what value would be assigned to artists[1]?
A
Beethoven
B
Chopin
C
Bach
D
3
A

A

Beethoven

37
Q
If you create a short array using the syntax var big3=["Chevy","Ford","Chrysler"];, what would the expression big3.length return after doing so?
A
3
B
Chrysler
C
0
D
17
A

A

3

38
Q
If you start a loop with for (var i = 10; i <= 100; i += 10), how many times will that loop repeat?
A
1.
B
100.
C
10.
D
90.
A

C

10.

39
Q
What is the meaning of the JavaScript ++ operator?
A
Decrement the value by 1.
B
Increment the value by 1.
C
Double the value of the variable.
D
Less than.
A

B

Increment the value by 1.

40
Q
Which JavaScript construct is often used in place of a long series of if . . . else statements when there are many options to consider?
A
Loop.
B
Ternary operator.
C
Switch statement.
D
Array.
A

C

Switch statement.

41
Q

In the JavaScript code setTimeout(“alert(‘Boo!’)”, 5000);, what does the 5000 represent?
A
The number of times the alert box will appear on the screen.
B
About half a second of time.
C
The maximum width of the alert box, in pixels.
D
Five seconds of time.

A

D. Five seconds of time.

42
Q
What's the correct syntax for calling a function named changesize() repeatedly every two seconds?
A
setInterval("changesize()", 2000)
B
setTimeout("changesize()", 2000)
C
setInterval("changesize()", 2)
D
setTimeout(2, "changesize()")
A
A
setInterval("changesize()", 2000)
43
Q
What is the definition of the term millisecond?
A
A millionth of a second.
B
A tenth of a second.
C
A thousandth of a second.
D
A hundredth of a second.
A

C

A thousandth of a second.

44
Q
What would be the correct syntax for stopping a timer named myTimer?
A
Clear interval (my timer)
B
myTimer.clearInterval
C
Clearinterval(myTimer)
D
clearInterval(myTimer)
A

D

clearInterval(myTimer)

45
Q

Which of the following best describes the purpose of the JavaScript .className property?
A
Creates a CSS style class in an internal style sheet.
B
Gets or sets the CSS style class that’s assigned to an element.
C
Creates a JavaScript class named Name.
D
Adds a CSS style class to an external style sheet.

A

B. Gets or sets the CSS style class that’s assigned to an element.

46
Q

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 in your site?
A
Use a fancy authoring program like Visual Studio to add jQuery capabilities to your website.
B
Create a CSS external style sheet, and then run it through a jQuery compiler to create your own library.
C
Make sure that when you select a computer to buy, it already has jQuery installed in it.
D
Link to the jQuery file on a Content Development Network like Google’s CDN or Microsoft’s CDN.

A

D

Link to the jQuery file on a Content Development Network like Google’s CDN or Microsoft’s CDN.

47
Q
What character is used throughout JavaScript code to call code in the jQuery library?
A
$
B
~
C
&amp;
D
%
A

A

$

48
Q

What does $(document).ready do in jQuery?
A
Tells the external style sheet when it’s okay to enter the page and start styling.
B
Lets the browser know when it’s okay to start rendering the HTML code.
C
Ensures that the page is loaded and ready to go before any jQuery code is executed.
D
Tells the person who is viewing the page in a browser when it’s okay to start entering jQuery code.

A

C

Ensures that the page is loaded and ready to go before any jQuery code is executed.

49
Q

What’s the primary difference between versions 1 and 2 of the jQuery library?
A
Version 1 includes support for older Internet Explorer versions 6 through 8, while version 2 does not.
B
Version 2 works in Webkit browsers like Safari and Chrome; Version 1 works in Mozilla browsers.
C
Version 2 can be downloaded from a CDN; version 1.9 has to be served from the hosting provider’s server.
D
Version 2 has effects like slideToggle and fadeToggle, while version 1 does not.

A

A

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

50
Q

Which best describes the action required to fire jQuery code that has the selector and event hander $(“img”).click?
A
The user clicks an image that has onclick=”img” in its tag.
B
The user clicks the paragraph that contains id=”img”.
C
The user clicks any image on the page.
D
The user clicks a div tag that contains class=”img”.

A

C

The user clicks any image on the page.

51
Q
Which of the following is another name for JavaScript?
A
ECMAScript.
B
Java.
C
PHP.
D
C#.
A

A. ECMAScript.

52
Q
Which event handler would be triggered by double-clicking an element on a Web page?
A
onmouseover
B
ondblclick
C
onclick
D
oncontextmenu
A

B

ondblclick

53
Q
Which DOM object is associated with the Web browser or user agent as a whole?
A
screen
B
location
C
window
D
navigator
A

D

navigator

54
Q
Which word best describes the meaning of the JavaScript || operator?
A
Not.
B
Or.
C
Equals.
D
And.
A

B

Or.

55
Q
In HTML, what are the  . . .  tags are used for?
A
To display radio buttons on a page.
The  tags are for radio buttons. The correct answer is: To define items in a drop-down list.
B
To define items in a drop-down list.
C
To display hyperlinks on a page.
D
To display a textbox on the page.
A

B

To define items in a drop-down list.

56
Q
When the .canPlayType property in JavaScript returns one of three possible values, "" or "maybe" or a third value, what's the third possible value?
A
"probably"
B
"mp3"
C
true
D
"yes"
A

A

“probably”

57
Q
If the variable x contains the string value goober, what would x.substr(1,3) return?
A
1o3ber
B
ber
C
oob
D
goo
A

C

oob

58
Q
If the JavaScript statement var total = taxable ? price * 1.06 : price; uses a shorthand if syntax to make a decision, what does that syntax use to make the decision?
A
Do while loop.
B
Ternary operator.
C
Array object.
D
Switch statement.
A

B

Ternary operator.

59
Q
Which of the following are JavaScript timing events?
A
for, while
B
setInterval, setTimeout
C
onload, onunload
D
if, switch
A

B

setInterval, setTimeout

60
Q
Which of the following best describes jQuery?
A
A JavaScript library.
B
A language for querying databases.
C
An external style sheet language.
D
A JavaScript editing program.
A

A

A JavaScript library

61
Q
Which language has built-in effects that make quick work of creating clickable, collapsible panel and accordion controls on Web pages?
A
JavaScript.
B
HTML.
C
CSS.
D
jQuery.
A

A

JavaScript.

62
Q
What do we call jQuery code that is written by others and is free to incorporate into your own site?
A
Browser plugins.
B
Browser add-ons.
C
jQuery plugins.
D
jQuery add-ons.
A

C

jQuery plugins.

63
Q

What does the jQuery toggleClass() method do?
A
Make an element fade in and out of view.
B
Display an on-and-off toggle switch on the page for changing JavaScript classes.
C
Switch between different CSS classes for styling an element.
D
Returns true if there’s a CSS class named toggle applied to an element.

A

C.

Switch between different CSS classes for styling an element.

64
Q
What is the correct syntax for making an element slide into and out of view quickly?
A
.slideToggle(12000)
B
.slideToggle("fast")
C
.slideToggle(10ms)
D
.slideToggle(quick)
A

B

.slideToggle(“fast”)

65
Q

What’s the meaning of the jQuery selector $(‘.wookie p’)?
A
The paragraph that contains class=”wookie” in its opening <p> tag.
B
All wookie elements inside the most recently clicked paragraph.
C
The div whose opening tag contains id=”wookie p”.
D
All paragraphs inside an element whose opening tag includes class=”wookie”.</p>

A

D

All paragraphs inside an element whose opening tag includes class=”wookie”.

66
Q
If you create a CSS style class to display one background image and then create a second CSS style class to display a different background image, which jQuery method would allow you to switch between the two different background images?
A
.classToggle()
B
.toggle()
C
.fadeToggle()
D
.toggleClass()
A

D

.toggleClass()

67
Q

Which of the following best describes jQuery decision-making?
A
jQuery decision making is limited to comparing the values of numeric variables.
B
jQuery does allow if . . . then decisions but requires using an unusual syntax similar to HTML.
C
There’s no way to make if . . . then decisions within a block of jQuery code.
D
jQuery uses the same syntax as JavaScript for if . . . then decisions.

A

D

jQuery uses the same syntax as JavaScript for if . . . then decisions.

68
Q

What’s the biggest challenge to using jQuery plugins?
A
The licensing is strict, and you must pay a fee and fill out extensive forms to use a plugin.
B
The documentation is sparse, at best. The authors assume you can figure everything out on your own.
C
You must install specialized software in your authoring system and browser to use them.
D
There is no place you can go to on the Web to find jQuery plugins.

A

B

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

69
Q
What is a widely used online version-control system and code repository for all kinds of software (not just jQuery plugins)?
A
jQuery Plugins Registry.
B
Mozilla Extensions Page.
C
Microsoft Add-Ins Page.
D
GitHub.
A

D

GitHub.

70
Q

What does it mean if a jQuery plugin claims to be swipeable?
A
The plugin shows little buttons on the screen that the user can click with a mouse.
B
You can add it to your page just by dragging a copy from the registry into your page’s source code.
C
Other people can easily steal it from your website.
D
People with touchscreens can control it by swiping their finger across the screen.

A

D

People with touchscreens can control it by swiping their finger across the screen.

71
Q

What are the MIT and GPL licenses commonly associated with?
A
Software that requires a signed contract from the author before you’re allowed to use it in your own work.
B
Compiled code that you can use without ever seeing or touching the original source code.
C
Software that always requires paying an annual fee to use in your own work.
D
Open source software that you are free to use in your own work.

A

D

Open source software that you are free to use in your own work.

72
Q

What do people who share jQuery plugins tend to assume about you, a person who’ll be using the code in your own sites?
A
You don’t know much about computers, so they’ll give step-by-step instructions for adding the plugin to your browser.
B
You have some knowledge or programming, but not necessarily Web development.
C
You have bottomless buckets of money and can pay exorbitant fees to use their plugins.
D
You understand HTML, CSS, JavaScript, and jQuery well enough that you can figure things out on your own.

A

D

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