webpage interactivity Flashcards

1
Q

what does document.getElementById() return

A

a single element and null if its not found

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

what does document.getElementByClassName() return

A

a collection of all elements with the class

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

what does document.getElementByTagName() return

A

a collection of all elements with the tag

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

what does document.querySelector() return

A

first matching element of the selector

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

what does document.querySelectorAll() return

A

all matching elements of the selector

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

what are events

A

user interactions or browser actions that js can detect and respond to

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

in which two ways can we attach events to elements

A

inline event handlers
using addEventListener()

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

inline event listeners

A

events are added in html attributes

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

what is the issue with using inline event handlers

A

mixing js and html may be hard to maintain

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

what is the benefit of using addEventListener()

A

allows you to have multiple event listeners for an element

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

what is react

A

open source js library for ui components

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

how is react declarative and what are the benefits of this

A

makes code more predictable and easy to debug as it automatically updates the dom to match the components state

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

how is react component-based and what is the benefit of this

A

builds encapsulated components that manage their own state
each component can be reused meaning more manageable code

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

what are components and what can they accept

A

modular reusable units (functions/classes) that come together to form the ui
they can optionally accept an input and return a react element

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

what does a react element do

A

defines how a specific part of the code should be displayed

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

what is a state

A

a js variable managed by react to store a components dynamic data

17
Q

what makes a state different to other js variables

A

persists across re-renders; when the state changes react automatically re-renders the component to reflect the new state

18
Q

what are props(properties)

A

a way to pass data from a parent to child component
allowing components to communicate

19
Q

what is a benefit of using props

A

makes components reusable and dynamic by allowing different values to be passed in

20
Q

jsx

A

allows you to write html-like code inside js
used by react components to represent the markup that is rendered by react into the browser