JavaScript Flashcards
What is responsive design?
- Design where UI changes based on certain factors, ex.) state change, type of user, screen width
- Beholden to factors beyond itself- changes depending on a variable
What is RESTful API?
- Representational State Transfer
- An API which follows a certain architectural structure and certain principles
- Defines a set of functions(GET/PUT/POST/DELETE) that the client uses to access server data using HTTP protocols
Principles being:
It should be stateless(server does not save client data)
It should access all the resources from the server using only URI
It does not have built in encryption
It does not have session
It uses one and only one protocol - HTTP
What is the difference between REST API and RESTful API?
REST is the set of constraints. RESTful refers to an API adhering to those constraints.
What is a closure?
- Inner functions that have access to outer functions scope (variables and parameters)
- The combination of a function and its surrounding state
What is a promise?
A promise is the expectation of a function to return data. Its useful in programming because it allows other non promise related functions to run without having to wait for the promise to resolve.
What is a callback?
- A function passed as an argument to another another function in order to complete the function it was passed into
- Allows a function to call another function after it has finished executing
What is AJAX?
- Asynchronous Javascript and XML
- Allows webpages to be updated asynchronously by exchanging data with a web server behind the scenes
- Enables parts of a webpage to be updated without reloading the whole page
- Fetch API interface allows web browser to make HTTP request to web server
What’s the benefit of using async/await?
- Increase in performance and responsiveness, can perform other tasks while waiting for result from long running task
- Organizes code in neat/readable and more concise way making code more maintainable
- Use as opposed to promises or callbacks
- Await is basically syntactic sugar for Promises
What is cookie? cookies vs localStorage vs sessionStorage?
- Cookies are pieces of data from a website stored on a user’s browser that the website can retrieve at a later time, used to tell the server that a user has returned to a particular website, can store string value only (less than 4kb)
- sessionStorage is data that gets deleted when the browser is closed, can store string value and object (5-10 mb)
- localStorage uses client’s computer to store data even after window or tab has been closed, stores with key/values serialized as string (up to 5mb)
What is prototypal inheritance?
- Objects use it to add or inherit methods and properties
- Each javascript object has a property which holds a link to another object called the prototype. That prototype has its own prototype and the link continues until an object has a prototype of null.
What is the DOM?
- Document Object Model
- The DOM is a node based programming interface for HTML and XML documents
- Defines logical structure of documents & the way it is accessed/manipulated
How to copy an Array?
-Using the spread operator to create a shallow copy
How to compare two objects?
Stringify both the objects and compare their values.
What is asynchronous programming and why is it important in JavaScript?
- Technique that enables a program to run a task and still be responsive to other events at the same time, ex) making HTTP requests with fetch
- JS uses event handlers or callbacks and promises/async await
What is hoisting?
Hoisting is Javascript’s default behavior of moving declarations to the top prior to execution. This allows variables to be used even before being declared.