Lesson 5: DOM Objects and Built-In Objects Flashcards

1
Q

What is BOM (DOM)?

A

the Browser Object Model.

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

What are two window methods?

A

alert() and prompt()

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

What is returned if the user clicks the cancel button on a prompt popup?

A

Null value.

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

What does confirm(“msg”) do?

A

Return true or false depending on which button is clicked on the popup.

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

Show an example of confirm():

A
let answer = confirm("is 3+2=5?");
if (answer==true) (alert("correct"); }
else {alert("wrong"); }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does getElementBiId() do?

A

Returns a reference to an element with the id specified.

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

Show an example of getElementById:

A
const h1 =
document.getElementById('title');
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is innerHTML used for?

A

Setting or changing element content.

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

What does the window.history object do?

A

Stores a list of the URLs previously visited using the current browser tab.

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

What does the location object contain?

A

Information about the currently loaded page.

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

What does the navigator object contain?

A

Data about the browser application.

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

Math.abs(a):

A

Returns the absolute value of a.

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

Math.celi(a):

A

Rounds a up to the next integer.

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

Math.floor(5.8):

A

Rounds a down to the next integer.

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

Math.round(a):

A

Rounds a to the nearest integer.

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

Math.sqrt(a):

A

Returns the square root of a.

17
Q

Math.max():

A

Gets the max value of its arguments.

18
Q

Math.min():

A

Gets the min value of its arguments.

19
Q

Math.random():

A

Creates random numbers between 0 and 1.

20
Q

Show a display of a random integer between 1 and 10:

A
let randomNum = Math.floor((Math.random() * 10) + 1);
let el = document.getElementById('info');
el.innerHTML = '<h1>random number</h1><p>' + randomNum + '</p>';
21
Q

What does the keyword ‘with’ do?

A

Takes an object as an argument and is followed by a code block.

22
Q

Show an example using the ‘with’ keyword:

A
with (math) {
var myRand = random();
var biggest = max(3,4,5);
var height = round(76.35);
}
23
Q

Create a date object with today’s date:

A

let myDate = new Date();

24
Q

Other ways to create a Date object:

A
  • new Date()
  • new Date(year, month, day, hrs, mins, secs, milliseconds)
  • new Date(milliseconds)
  • new Date(date string)
25
Q

What does alert() do?

A

Pauses all user interaction with the page until the user clears the dialog.

26
Q

Show an example of alert()

A

alert(“this is my message!”);

27
Q

What does prompt() do?

A

Opens a modal dialog, allowing users to enter information.

28
Q

Show an example of a prompt():

A

var answer = prompt(“What is your name?”, “John Doe”);