JavaScript Flashcards

1
Q

What is responsive design?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is RESTful API?

A
  • 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

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

What is the difference between REST API and RESTful API?

A

REST is the set of constraints. RESTful refers to an API adhering to those constraints.

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

What is a closure?

A
  • Inner functions that have access to outer functions scope (variables and parameters)
  • The combination of a function and its surrounding state
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a promise?

A

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.

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

What is a callback?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is AJAX?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What’s the benefit of using async/await?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is cookie? cookies vs localStorage vs sessionStorage?

A
  • 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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is prototypal inheritance?

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the DOM?

A
  • 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to copy an Array?

A

-Using the spread operator to create a shallow copy

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

How to compare two objects?

A

Stringify both the objects and compare their values.

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

What is asynchronous programming and why is it important in JavaScript?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is hoisting?

A

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.

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

let, var, const

A
  • Scope, declaration, assignment, hoisting
  • Var has global scope. Can be declared without initialization. Can be redeclared and reassigned. Var gets hoisted and initialized with undefined- can use before declaration
  • Let has block scope. Can be declared without initialization. Can be reassigned, but not redeclared. No initialization when hoisted
  • Const has block scope. Const must be initialized with a value when declared. Const cannot be redeclared or reassigned. No initialization when hoisted
17
Q

What’s the difference between a variable that is: null, undefined or undeclared? How would you go about checking for any of these states?

A
  • Undefined is a variable that has not been assigned a value
  • Null is the intentional absence of any object value, is a primitive value treated as falsy
  • Undeclared is a variable that was declared without const, let, or var
  • You can check using an equality operator
18
Q

What is higher order function?

A

A higher order function is a function that accepts functions as parameters and/or returns a function.

  • meaning they are data like a str/num/array etc.
    ex) store function as variable, use in an array, assign as object properties(methods)
19
Q

What is the difference between == and ===?

A

== Ignores datatype of variable - “2” == 2 // true

=== Looks for strict equality, checks for same datatype - “2” == 2 // false

20
Q

API

A
  • Application program interface- defines how software communicates
  • Used to connect applications in order to perform a designed function **built around sharing data and executing predefined processes**
  • Essentially ‘middlemen’

Web API => between web server and web browser

21
Q

Apply / Call / Bind

A
  • Bind: method used to create a new function that when called has its ‘this’ keyword set to the provided value, creates a bound function that wraps the original function
  • Call: method that calls a function with a given ‘this’ value and arguments provided individually, allows for function/method belonging to one object to be assigned and called for a different object
  • Apply: similar to call but parameters passed in as array
22
Q

What is the point of a RESTful API?

A
  • To have a uniform way of communication between browser and server
  • To have structure in which data moves between client and server