JS Simple Slide Show Flashcards

1
Q

What does DOM stand for?

A

DOM stands for Document Object Model.

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

What is the DOM used for?

A

The DOM is a programming interface for HTML and XML documents that represents the page so that programs can change its structure, style, and content dynamically.

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

How does the DOM represent an HTML document?

A

The DOM represents the HTML document as a tree structure where elements like <html>, <head>, <body>, and <div> become nodes in the DOM tree.

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

How can you access DOM elements using JavaScript?

A

You can access DOM elements using JavaScript by:

• ID (document.getElementById())

• Class name (document.getElementsByClassName())

• Tag name (document.getElementsByTagName())

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

How can JavaScript modify the DOM?

A

JavaScript can dynamically change the content, structure, and styles of elements by accessing and manipulating DOM elements.

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

What are JS events?

A

Events are actions or occurrences that happen in the browser, like clicks, keypresses, or page loads. JavaScript allows code to be executed in response to these events.

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

What are some common JavaScript events?

A

Some common JavaScript events include:

• click
• mouseover
• keydown
• load

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

What is an event listener?

A

An event listener is a method in JavaScript that allows you to run a function in response to a specific event, like a button click or a form submission.

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

What types of events can be handled using JavaScript?

A

Some types of events include:

• Mouse events
• Keyboard events
• Form events
• Document/window events

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

What is the difference between global, local, and block scope in JavaScript?

A

• Global scope: Variables accessible from anywhere in the code.

• Local (Function) scope: Variables only accessible within a function.

• Block scope: Variables declared with let and const are only accessible within the block in which they are defined.

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

What is the purpose of console.log() in JavaScript?

A

The console.log() method is used to print output to the browser’s console, allowing developers to debug by inspecting variables, expressions, and objects during code execution.

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

How do you open the console in a browser like Chrome?

A

Right-click on the page, select “Inspect,” and then open the “Console” tab.

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

What is block scope in JavaScript?

A

Block scope restricts the visibility of variables declared with let and const to the block in which they are defined. They cannot be accessed outside of this block.

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

What is an example of block scope in JavaScript?

A

if (true) {
let blockScoped = “I’m inside a block”;
console.log(blockScoped); // Accessible
}
console.log(blockScoped); // Error: blockScoped is not defined

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

How can you create a simple image slideshow using JavaScript?

A

You can create a simple slideshow by using JavaScript to manipulate the DOM and respond to events like button clicks or timers. The basic setup includes a function to show images, and additional functions to navigate between them.

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

What does the showSlide() function do in the slideshow?

A

The showSlide(index) function updates the image element’s src attribute to display the image at the specified index from an array of image file paths.

17
Q

What does the nextSlide() function do in the slideshow?

A

The nextSlide() function increments the currentSlide variable and updates the displayed image by calling showSlide(). It also wraps around to the first image when the last one is reached.

18
Q

How does prevSlide() work?

A

The prevSlide() function decrements the currentSlide variable and shows the previous image. If it’s on the first image, it wraps around to the last image in the array.

19
Q

What is setInterval() used for in the slideshow?

A

The setInterval() function automatically calls the nextSlide() function at regular intervals (e.g., every 3000 milliseconds), making the slideshow rotate through the images automatically.