JS Simple Slide Show Flashcards
What does DOM stand for?
DOM stands for Document Object Model.
What is the DOM used for?
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 does the DOM represent an HTML document?
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 can you access DOM elements using JavaScript?
You can access DOM elements using JavaScript by:
• ID (document.getElementById())
• Class name (document.getElementsByClassName())
• Tag name (document.getElementsByTagName())
How can JavaScript modify the DOM?
JavaScript can dynamically change the content, structure, and styles of elements by accessing and manipulating DOM elements.
What are JS events?
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.
What are some common JavaScript events?
Some common JavaScript events include:
• click
• mouseover
• keydown
• load
What is an event listener?
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.
What types of events can be handled using JavaScript?
Some types of events include:
• Mouse events
• Keyboard events
• Form events
• Document/window events
What is the difference between global, local, and block scope in JavaScript?
• 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.
What is the purpose of console.log() in JavaScript?
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 do you open the console in a browser like Chrome?
Right-click on the page, select “Inspect,” and then open the “Console” tab.
What is block scope in JavaScript?
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.
What is an example of block scope in JavaScript?
if (true) {
let blockScoped = “I’m inside a block”;
console.log(blockScoped); // Accessible
}
console.log(blockScoped); // Error: blockScoped is not defined
How can you create a simple image slideshow using JavaScript?
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.