JavaScript Midterm Exam Flashcards

1
Q

JavaScript is used to add ______ to web pages.

A

behavior

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

True or False?

Browsers begin executing JavaScript only when the entire page has loaded.

A

False

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

Add JavaScript to your page with the _____ element.

A

script

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

Use the _____ attribute in a tag to link to a separate JavaScript file.

A

src

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

JavaScript programs are made up of a series of ______.

A

algorithms

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

You can put your JavaScript in two places, ______ in the web page, or you can _____ to a separate file containing your JavaScript from your HTML.

A

right, link

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

One of the most common JavaScript statements is a variable declaration, which uses the _____ keyword to declare a new variable and the assignment operator, ____, to assign a value to it.

A

var, =

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

True or False?

JavaScript expressions compute values.

A

True

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

Three common types of expressions are ____, ______, and _____ expressions.

A

numeric, string, boolean

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

______ allow you to make decisions in your code.

A

if/else

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

____/____ statements allow you to execute code many times by looping.

A

while/for

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

Use ______ instead of alert to display messages to the Console.

A

console.log

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

True or False?

Console messages should be used primarily for sending messages to the users.

A

False

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

______ is the function provided for getting input from a user. If a user hits cancel instead of inputting data, _____ is returned from the function.

A

prompt, null

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

Code that continuously repeats itself without ever ending is called a(n) _______.

A

infinite loop

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

What is the ‘And’ Boolean operator in JavaScript symbolized by?

A

&&

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

______ is the function used in JavaScript for generating random numbers.

A

math.random

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

______ is the function that always rounds numbers down.

A

math.floor

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

Boolean operators always result in the values ____ or ______.

A

true, false

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

To get a false value from an OR operator (||) both values must be ______.

A

false

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

_______ is an English approximation of what your code should do.

A

psuedocode

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

What happens if you pass too many arguments to a function in JavaScript?

A

It ignores the extra arguments and runs perfectly fine.

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

True or False?

In JavaScript, the return type needs to be declared in the function signature.

A

False

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

A variable declared outside of a function is called a _______ variable.

A

global

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
A variable declared inside of a function is called a ______ variable.
local
26
The area of code in which you can use a variable is called the variable's ______.
scope
27
If you forget to declare a variable inside of a function, its scope will be ______.
global
28
True or False? | JavaScript requires a function to be defined prior to the point of calling it in the code.
False
29
What method allows you to add a value to the end of an array?
.push();
30
An array item that has not been initialized will have the value: _______.
undefined
31
True or False? | In JavaScript, arrays may grow beyond their initialized size.
True
32
You identify an element in an array using its ______.
index
33
Which property of an array will tell you the number of items in the array?
.length
34
A ______ array occurs when there are undefined terms in the middle of an array.
sparse
35
______ is the process of organizing your code so that it is easier to read and maintain.
refactoring
36
_______ is looping through each item in an array to process each item.
iterating
37
The index of the first item in an array is _____.
0
38
The last index of an array is always one ____ than the length of the array.
less
39
JavaScript objects are a collection of _______ and _______.
Properties, Behaviors
40
When declaring an object, each property of an object has a name followed by a _____ then a value.
colon
41
When declaring an object, properties are separated from each other by a ______.
comma
42
To access a property of an object you use _______ notation.
dot
43
You can remove a property from an object using the _____ operator.
delete
44
Variables for objects hold a _______ to the object.
reference
45
_______ is a keyword that always refers to the object whose method is being called.
this
46
True or False? | A method is a function that has been assigned to a property name in an object.
True
47
You can iterate through an object's properties using a _______.
for each
48
Object references are passed by _______, just like primitive variables.
values
49
DOM stands for __________.
Document Object Model
50
To find and access an element on a web page using its ID, use the _______ method of the _______ object.
getElementByID, document
51
To access or change the contents of an element you can alter its _________ property.
innerHTML
52
True or False? | ID's on a web page must be unique.
True
53
True or False? | Classes on a web page must be unique.
False
54
______._______ is the object and property that will call a function only after the web page is fully loaded.
window.onload
55
Giving a function to an object that knows about an event so that it runs the code when the event happens is known as a _________ function or an event handler.
callback
56
To get the value of an attribute of an HTML element, use the ________ method.
getAttribute
57
To change an attribute of an HTML element, use the ________ method.
setAttribute
58
Anytime you call method to locate an element or attribute that does not exist, ______ is returned.
null
59
True or False? | The web browser creates the DOM for the web page.
True
60
True or False? | The innerHTML property holds only the text content of an element.
False