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
Q

A variable declared inside of a function is called a ______ variable.

A

local

26
Q

The area of code in which you can use a variable is called the variable’s ______.

A

scope

27
Q

If you forget to declare a variable inside of a function, its scope will be ______.

A

global

28
Q

True or False?

JavaScript requires a function to be defined prior to the point of calling it in the code.

A

False

29
Q

What method allows you to add a value to the end of an array?

A

.push();

30
Q

An array item that has not been initialized will have the value: _______.

A

undefined

31
Q

True or False?

In JavaScript, arrays may grow beyond their initialized size.

A

True

32
Q

You identify an element in an array using its ______.

A

index

33
Q

Which property of an array will tell you the number of items in the array?

A

.length

34
Q

A ______ array occurs when there are undefined terms in the middle of an array.

A

sparse

35
Q

______ is the process of organizing your code so that it is easier to read and maintain.

A

refactoring

36
Q

_______ is looping through each item in an array to process each item.

A

iterating

37
Q

The index of the first item in an array is _____.

A

0

38
Q

The last index of an array is always one ____ than the length of the array.

A

less

39
Q

JavaScript objects are a collection of _______ and _______.

A

Properties, Behaviors

40
Q

When declaring an object, each property of an object has a name followed by a _____ then a value.

A

colon

41
Q

When declaring an object, properties are separated from each other by a ______.

A

comma

42
Q

To access a property of an object you use _______ notation.

A

dot

43
Q

You can remove a property from an object using the _____ operator.

A

delete

44
Q

Variables for objects hold a _______ to the object.

A

reference

45
Q

_______ is a keyword that always refers to the object whose method is being called.

A

this

46
Q

True or False?

A method is a function that has been assigned to a property name in an object.

A

True

47
Q

You can iterate through an object’s properties using a _______.

A

for each

48
Q

Object references are passed by _______, just like primitive variables.

A

values

49
Q

DOM stands for __________.

A

Document Object Model

50
Q

To find and access an element on a web page using its ID, use the _______ method of the _______ object.

A

getElementByID, document

51
Q

To access or change the contents of an element you can alter its _________ property.

A

innerHTML

52
Q

True or False?

ID’s on a web page must be unique.

A

True

53
Q

True or False?

Classes on a web page must be unique.

A

False

54
Q

______._______ is the object and property that will call a function only after the web page is fully loaded.

A

window.onload

55
Q

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.

A

callback

56
Q

To get the value of an attribute of an HTML element, use the ________ method.

A

getAttribute

57
Q

To change an attribute of an HTML element, use the ________ method.

A

setAttribute

58
Q

Anytime you call method to locate an element or attribute that does not exist, ______ is returned.

A

null

59
Q

True or False?

The web browser creates the DOM for the web page.

A

True

60
Q

True or False?

The innerHTML property holds only the text content of an element.

A

False