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
Q

What is the difference when connecting to socket.io server from the client when on the EBS?

A

The connect function is passed no arguments
io.connect()

26
Q

What does Math.floor() do?

A

Rounds a number DOWN to the nearest integer

27
Q

What does Math.random() return?

A

Random floating number between [0, 1)

28
Q

What 3 event handlers were needed for someone joining the server in Case 2?

A
  1. nameexists
  2. welcome
  3. someonejoined
29
Q

What listener on the server side handles when a client disconnects?

A

socket.on(“disconnect”, …)

30
Q

What is Moment.js used for?

A

Handling date and times

31
Q

How do you format a date with Moment?

A

moment().format(‘date format’)

32
Q

How do you broadcast a message to everyone in the room including the sender?

A

io.in(roomName).emit(“funcName”, “message”)

33
Q

What property is used to handle pressing enter to send a message in Case 2?

A

onKeyPress={ }

34
Q

Why is the useRef hook used in Case 2?

A

scrollIntoView property

35
Q

The TopBar component uses what Material UI component?

A

Toolbar

36
Q

What is the TopBar button made of?

A

IconButton and SVG icon

37
Q

What triggers a Dialog component to show?

A

open={ }

38
Q

How do you set the timezone in app.js for Case 2?

A

process.env.TZ = “America/New_York”

39
Q

PWA

A

Progressive Web Apps

40
Q

What is a PWA?

A

Blends features of a native app and a website

41
Q

What is the key difference between PWA and a native app?

A

PWA runs in the browser

42
Q

PWAs are Really Fucking Exciting

A

Reliable
Fast
Engaging

43
Q

Why are PWA considered reliable?

A

Immediately loads and never shows website is down

44
Q

Where does the developer put all the metadata for a PWA?

A

Manifest

45
Q

What allows a PWA to allow for offline browsing, caching, background sync and push notifications?

A

Service Workers

46
Q

What kind of icon was used for the PWA?

A

Maskable Icon

47
Q

Where do you reference the manifest?

A

index.html

48
Q

Where is the service worker code that gets registered?

A

sw.js

49
Q

What are the 4 states of a service worker?

A
  1. Installing
  2. Activated
  3. Idle
  4. Fetch/Message
50
Q

If the PWA is offline in what is returned from the service worker fetch?

A

offline.html

51
Q

Where do you see the service worker?

A

Application tab in browser

52
Q

Where do you go to get an audit of your PWA?

A

Lighthouse