JS Questions Flashcards

1
Q

Explain event delegation.

A

Event Delegation is a pattern based upon the concept of Event Bubbling. It is an event-handling pattern that allows you to handle events at a higher level in the DOM tree other than the level where the event was first received.

EX: Click Me! button. Due to event bubbling, when the button receives an event, say click, that event bubbles up the tree, so span and div will respectively receive the event also.

const div = document.getElementsByTagName(“div”)[0]

div.addEventListener(“click”, (event) => {
if(event.target.tagName === ‘BUTTON’) {
console.log(“button was clicked”)
}
})

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

Explain how prototypal inheritance works.

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

What’s the difference between a variable that is: null, undefined or undeclared?
How would you go about checking for any of these states?

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

What is a closure, and how/why would you use one?

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

What language constructions do you use for iterating over object properties and array items?

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

Can you describe the main difference between the Array.forEach() loop and Array.map() methods and why you would pick one versus the other?

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

What’s a typical use case for anonymous functions?

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

What’s the difference between host objects and native objects?

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

Explain the difference between: function Person(){}, var person = Person(), and var person = new Person()?

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

Explain the differences on the usage of foo between function foo() {} and var foo = function() {}

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

Can you explain what Function.call and Function.apply do? What’s the notable difference between the two?

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

Explain Function.prototype.bind.

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

What’s the difference between feature detection, feature inference, and using the UA string?

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

Explain “hoisting”.

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

Describe event bubbling.

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

Describe event capturing.

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

What’s the difference between an “attribute” and a “property”?

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

What are the pros and cons of extending built-in JavaScript objects?

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

What is the difference between == and ===?

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

Explain the same-origin policy with regards to JavaScript.

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

Why is it called a Ternary operator, what does the word “Ternary” indicate?

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

What is strict mode? What are some of the advantages/disadvantages of using it?

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

What are some of the advantages/disadvantages of writing JavaScript code in a language that compiles to JavaScript?

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

What tools and techniques do you use debugging JavaScript code?

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

Explain the difference between mutable and immutable objects.

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

What is an example of an immutable object in JavaScript?

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

What are the pros and cons of immutability?

A
28
Q

How can you achieve immutability in your own code?

A
29
Q

Explain the difference between synchronous and asynchronous functions.

A
30
Q

What is event loop?

A
31
Q

What is the difference between call stack and task queue?

A
32
Q

What are the differences between variables created using let, var or const?

A
33
Q

What are the differences between ES6 class and ES5 function constructors?

A
34
Q

Can you offer a use case for the new arrow => function syntax? How does this new syntax differ from other functions?

A
35
Q

What advantage is there for using the arrow syntax for a method in a constructor?

A
36
Q

What is the definition of a higher-order function?

A
37
Q

Can you give an example for destructuring an object or an array?

A
38
Q

Can you give an example of generating a string with ES6 Template Literals?

A
39
Q

Can you give an example of a curry function and why this syntax offers an advantage?

A
40
Q

What are the benefits of using spread syntax and how is it different from rest syntax?

A
41
Q

How can you share code between files?

A
42
Q

Why you might want to create static class members?

A
43
Q

What is the difference between while and do-while loops in JavaScript?

A
44
Q

What is a promise? Where and how would you use promise?

A
45
Q

Discuss how you might use Object Oriented Programming principles when coding with JavaScript.

A
46
Q

Explain Callbacks in JavaScript.

A
47
Q

Explain NaN in JavaScript.

A
48
Q

Explain the different data types in JavaScript.

A
49
Q

Explain Object Destructuring in JavaScript.

A
50
Q

What is a Spread Operator?

A
51
Q

What is a Rest Operator

A
52
Q

What is a Rest Syntax

A
53
Q

Explain events in JavaScript.

A
54
Q

Explain setTimeout and setInterval methods in JavaScript.

A
55
Q

Explain debouncing and throttling in JavaScript.

A
56
Q

Explain the different scopes in JavaScript.

A
57
Q

Explain Scope Chain in JavaScript.

A
58
Q

When can you have an error that says Undefined Value on the screen?

A
59
Q

How is the button configuration in the Confirmation box different from the Alert box in JavaScript?

A
60
Q

On a client machine, how do you detect the server using JavaScript?

A
61
Q

What, according to you, are the differences between Java and JavaScript?

A
62
Q

What are timers in JavaScript?

A
63
Q

What is the use of Void (0)?

A
64
Q

How can a page be forced to load another page in JavaScript?

A
65
Q

What is the role of deferred scripts in JavaScript?

A