Exam Flashcards
What is the DOM?
Interface of a web app
What is diffing?
Comparing the virtual DOMs for differences and re-rendering the real DOM with only these changes
Why does React use virtual DOMs?
Speed
What protocol does socket.io use?
Engine.IO
What kind of connection does socket.io try first?
Websocket
What kind of connection does socket.io use as a backup?
HTTP Long Polling
In socket.io, what is the server instance called?
io
Why did we use Express instead of Fastify?
Fastify is better for API calls, but in Case 2 we didn’t make any
What was imported from socket.io on the server side?
Server
How do you initialize the server instance?
const io = new Server( httpServer, { } ) ;
What was installed for the client side of socket.io?
socket.io-client
How do you initialize the socket instance on the client side?
const socket = io.connect(“localhost:5000”, { options });
What function sets up a listener in socket.io?
on(“name”, listener())
How do you send a message to the joining client from the server?
socket.emit(“funcName”, “message”)
How do you send a message to the rest of the room from the server when a client first joins?
socket.to(“room”).emit(“funcName”, “message”)
How do you get the number of clients in a room?
io.sockets.adapter.rooms.get(roomName).size
How do you test if the server is trying to connect on the client side?
socket.io._readystate === “opening”
How do you test if the client has failed to connect to the server?
socket.io._readystate === “closed”
What is the private property that every JavaScript object has that points to a second object?
Prototype
A new instance of Number inherits from which prototype?
Number.prototype and Object.prototype