JavaScript Flashcards
What are the main HTTP methods?
GET, POST, PUT/PATCH, DELETE. REST APIs.
interact with data from servers.
HTTP Status Codes?
100 level - information status 200 level - success response 300 - redirect 400 - client-side error (ie. 404) 500 - server error
Sync vs Async code?
synchronous - going in order.
asynchronous - go “do something” while rest of code continues. JS is single-threaded, but allows multiple things to happen at once.
What is a promise?
An easy way of handling asynchronous data. Useful for things like user input. will always either resolve or reject, then can handle accordingly. can chain promises with .then, i.e. using Fetch api. async await with ES6 is cleaner way of doing the same thing. need to use try/catch block when using async await.
how does async await work?
cleaner way of using promises. not chaining promises. async function, await the result. benefit is non-nesting, cleaner code. use try/catch to catch any errors.