Backend Flashcards

1
Q

What is a promise

A

An object that may have a value later on

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

A promise can have three possible states

A
  1. pending - initial state, neither fulfilled nor rejected
  2. fulfilled - meaning that the operation was completed successfully
  3. Rejected - meaning that the operation failed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

async function getPaid(){
const houseOneWait = await houseOne()
const houseTwoWait = await houseTwo()
const houseThreeWait = await houseThree()
console.log(houseOneWait)
console.log(houseTwoWait)
console.log(houseThreeWait)
}
getPaid()

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

What is an API’s fetch

A
async function getACuteDogPhoto(){
    const res = await fetch('https://dog.ceo/api/breeds/image/random')
    const data = await res.json()
    console.log(data)
}
getACuteDogPhoto()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Javascript, does it run in the browser?

A

Yes

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

JavaScript is running where in the browser

A

Sandboxed, it can’t get access to the browser in the computer

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

JS is a language that can only do what the hosting environment allows

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

What do servers do?

A

They serve up files

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

What do servers do?

A

They serve up files

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

What is Node.js

A

Node.js

The same stuff that lets you run JS in the browser can now be used to run JS on Servers, Desktops, and elsewhere

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

Just
HTTP & FS

const http = require('http')
const fs = require('fs')
http.createServer((req, res) => {
  fs.readFile('demofile.html', (err, data) => {
    res.writeHead(200, {'Content-Type': 'text/html'})
    res.write(data)
    res.end()
  })
}).listen(8000)
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly