General Trivia Flashcards

1
Q

What’s the difference between stopPropagation and preventDefault?

A

stopPropagation prevents further propagation of the current event in the capturing and bubbling phases.

preventDefault prevents the default action the browser makes on that event.

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

What does stopImmediatePropagation do?

A

stopImmediatePropagation() method of the Event interface prevents other listeners of the same event from being called.

If several listeners are attached to the same element for the same event type, they are called in the order in which they were added. If stopImmediatePropagation() is invoked during one such call, no remaining listeners will be called.

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

document.getElementsByTagName vs. document.querySelector()

A

The getElementsByTagName method of Document interface returns an HTMLCollection of elements with the given tag name.

The Document method querySelector() returns the first Element within the document that matches the specified selector, or group of selectors. If no matches are found, null is returned.

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

What kinds of operations result in O(1) time?

A
Assignment operator (printing, returning, comparing), mathematics, any fixed string, even if you're iterating through the string, because it's fixed and 
strings are immutable in JS.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What results in an O(n) time?

A

Iterating through arrays, the time it takes to go through the array is the amount of time (proportional) to go through the whole array.

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

What results in an O(n^2) time?

A

Usually nested loops, BUT not always!

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