Exam Flashcards

1
Q

What is the DOM?

A

Interface of a web app

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

What is diffing?

A

Comparing the virtual DOMs for differences and re-rendering the real DOM with only these changes

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

Why does React use virtual DOMs?

A

Speed

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

What protocol does socket.io use?

A

Engine.IO

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

What kind of connection does socket.io try first?

A

Websocket

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

What kind of connection does socket.io use as a backup?

A

HTTP Long Polling

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

In socket.io, what is the server instance called?

A

io

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

Why did we use Express instead of Fastify?

A

Fastify is better for API calls, but in Case 2 we didn’t make any

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

What was imported from socket.io on the server side?

A

Server

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

How do you initialize the server instance?

A

const io = new Server( httpServer, { } ) ;

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

What was installed for the client side of socket.io?

A

socket.io-client

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

How do you initialize the socket instance on the client side?

A

const socket = io.connect(“localhost:5000”, { options });

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

What function sets up a listener in socket.io?

A

on(“name”, listener())

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

How do you send a message to the joining client from the server?

A

socket.emit(“funcName”, “message”)

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

How do you send a message to the rest of the room from the server when a client first joins?

A

socket.to(“room”).emit(“funcName”, “message”)

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

How do you get the number of clients in a room?

A

io.sockets.adapter.rooms.get(roomName).size

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

How do you test if the server is trying to connect on the client side?

A

socket.io._readystate === “opening”

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

How do you test if the client has failed to connect to the server?

A

socket.io._readystate === “closed”

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

What is the private property that every JavaScript object has that points to a second object?

A

Prototype

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

A new instance of Number inherits from which prototype?

A

Number.prototype and Object.prototype

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

What is the hierarchy of prototypes called?

A

Prototype Chain

22
Q

Nearly all of JavaScript’s built-in constructors inherit from what?

A

Object.prototype

23
Q

What is the prototype chain used for?

A

If a property isn’t one of the object’s own properties the prototype chain will be checked for the property

24
Q

What does Object.create() do?

A

Creates an object using the prototype of the first argument

25
What is the difference when connecting to socket.io server from the client when on the EBS?
The connect function is passed no arguments io.connect()
26
What does Math.floor() do?
Rounds a number DOWN to the nearest integer
27
What does Math.random() return?
Random floating number between [0, 1)
28
What 3 event handlers were needed for someone joining the server in Case 2?
1. nameexists 2. welcome 3. someonejoined
29
What listener on the server side handles when a client disconnects?
socket.on("disconnect", ...)
30
What is Moment.js used for?
Handling date and times
31
How do you format a date with Moment?
moment().format('date format')
32
How do you broadcast a message to everyone in the room including the sender?
io.in(roomName).emit("funcName", "message")
33
What property is used to handle pressing enter to send a message in Case 2?
onKeyPress={ }
34
Why is the useRef hook used in Case 2?
scrollIntoView property
35
The TopBar component uses what Material UI component?
Toolbar
36
What is the TopBar button made of?
IconButton and SVG icon
37
What triggers a Dialog component to show?
open={ }
38
How do you set the timezone in app.js for Case 2?
process.env.TZ = "America/New_York"
39
PWA
Progressive Web Apps
40
What is a PWA?
Blends features of a native app and a website
41
What is the key difference between PWA and a native app?
PWA runs in the browser
42
PWAs are Really Fucking Exciting
Reliable Fast Engaging
43
Why are PWA considered reliable?
Immediately loads and never shows website is down
44
Where does the developer put all the metadata for a PWA?
Manifest
45
What allows a PWA to allow for offline browsing, caching, background sync and push notifications?
Service Workers
46
What kind of icon was used for the PWA?
Maskable Icon
47
Where do you reference the manifest?
index.html
48
Where is the service worker code that gets registered?
sw.js
49
What are the 4 states of a service worker?
1. Installing 2. Activated 3. Idle 4. Fetch/Message
50
If the PWA is offline in what is returned from the service worker fetch?
offline.html
51
Where do you see the service worker?
Application tab in browser
52
Where do you go to get an audit of your PWA?
Lighthouse