OMM Flashcards

(108 cards)

1
Q

What are some features of javascript

A
  • Functional programming -> Immutablility, like evaluation of functions
  • Dynamic typing (No static types)
  • First-class functions -> Function is a like variable (e.g. callbacks)
  • Huge ecosystem
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you debug java script applications

A
  • Browser console

- Page inspector

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

What is the difference in defining functions with keyword and with arrow functions

A
  • () => {} - Can’t be bind to names - Anonymous

- function bla(): Bind to a name

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

When are fat arrow function used

A

E.g. callbacks

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

How does object destructuring works?

A
  • let {foo, bar, baz}= obj; -> same like var foo = obj.foo
  • Spread operator … copies other keys of the object into new object with name: let{foo, …rest} = obj; rest.bar == obj.bar;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are standard prototype array functions?

A
  • Map: Change every element
  • Reduce: Aggregate, Accumulate
  • Foreach: Iterate
  • Filter: Filter
  • Find: Returns object -> Array
  • FindFirst: Just first ones -> First
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Shorten the following code: var array = new array(3)

A

let arr = [2,3,4];

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

Shorten following code: if foo: return bar; else: return null

A

return foo ? bar : null

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

What is a promise?

A
  • Wrapper for async code
  • Promise that a response arrives at some time
  • If completes: Resolved / fulfilled
  • If fails: Rejected
  • Can be chained with .then or .catch
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the keywords async & await?

A
  • Making functions async wraps the function into a promise

- Await waits for a promise and pauses it at the position till the promise resolves

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

Describe the difference between let and var and const

A
  • Let is mutable and can be reassigned
  • Var is old method for every variable
  • Const value is mutable but not the assignment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the result of

[ 1, 2, 3, 4 ].map((a) => a * a).reduce((a, b) => a + b)

A
  • [1, 4, 9, 16].reduce((a, b) => a + b)

- 30

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
Why will this fail:
function () { 
    const value = await fetch('http://httpbin.org/get'); 
    .then((res) => res.json());
    return value; 
}
A

no async on function delcaration

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

What are main components of a HTTP request?

A
  • request line: get / put
    • header: content-type, accept-type
    • body: body
    • response: status, header, body
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are some common http codes

A
  • 1xx Informational
    • 2xx Success
    • 3xx Redirect
    • 4xx Client error
    • 5xx Server error
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are common http methods

A
  • GET
    • POST
    • PUT
    • DELETE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

For what stands AJAX?

A

Asynchronous JavaScript and XML

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

What are the advantages of using JSON?

A
  • No fixed schema
    • Human readable
    • Easily convertible to JS
    • More dynamic
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are the advantages of using XML?

A
  • Fixed schema

- Namespace

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

What is the XMLHTTPRequest?

A
  • API to transfer data between client, server

- Not used anymore

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

What does fetch in JS?

A
  • Simplifying ajax requests

- Use promises for resolving

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

What are differences between XHR and fetch

A
  • XHR
    • Event-callback based
    • Create object
    • Open URL
    • Attach readystatechange
    • Send
    • Fetch
      • Promise based
      • Inside javascript function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How are Web APIs often secured?

A
  • Rate limits - requests per user
    • Scope of each user
    • Access token
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is the difference between authorization vs authentication

A
  • Authentication: Who am I?

- Authorization: What am I allowed to do?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are different ways to ensure authentication?
- Basic authentication: Username + Password - pro: quick and easy - con: Security issue - Personal access token - Pro: Security improvement - OAuth Token - Pro: Security (lifespan, exchanged regularly) - Con: More complicated to implement
26
What is Same Origin Policy?
- Tried to hamper cross site scripting | - Blocks ajax requests from other origins as defined in allowed origins
27
What does asynchronous actually mean?
That it doesn't block the whole program
28
What is the difference between get and post?
- Post alters something, e.g. create user | - Get just gets information, e.g. get user list
29
How do you avoid SOP(Same Origin Policy) issues?
- Define cross origins - JSON with padding - Reverse proxies
30
Why do we need an eventloop?
- Because javascript is single threaded - But somehow we need to execute code "at the same time" - E.g. callbacks, promises, etc.
31
What are the different event loops?
- Main loop: Executes sequential code - Message loop: Waites for enqueued messages - Rendering: Calculates stylesheet, results layout, paints webpage
32
What types are in javascript?
- undefined - number - string - boolean - Object - symbol - any
33
How can we check types?
- Typeof | - Instanceof
34
What is typescript?
- Superset of javascript | - JS with type annotations
35
Benefits of Typescript
- More concise / accurate code - More developer control - Static checking
36
Why does it make sense to keep JS single threaded?
- Because browser is single threaded as well | - Don't consume too much resources of user
37
How does JS convert from int to float?
Point after the number
38
Explain the difference between imperative and declarative?
- Imperative: Specify how to do something | - Declarative: Specify what should be done
39
Explain the MVC model
- Model: Data structure / model - View: Everything user sees - Controller: How things work / Behaviour
40
What is the goal of web components?
Having re-usable code
41
What are the main concepts of web components?
- Custom Elements - HTML Import - Templates - Shadow DOM
42
What are advantages of web components?
- More declarative - More readable - Separation of concerns - Re-Usable - Encapsulation
43
What is a polyfill?
Polyfill is a script which implements a workaround for things which are not implemented
44
What does the shadow DOM?
- Includes DOM Elements into rendering but not in main document - Hides implementation details -> Encapsulatin
45
Which of these are imperative and which are declarative?
- HTML: Declarative - JavaScript: Both - Java: Imperative - SQL: Declarative - Typescript: Both
46
What is a polyfill for?
Workaround for functions which are not implemented in the browser
47
What is a polyfill for?
Workaround for functions which are not implemented in the browser
48
What is React.js?
Javscript framework for building web applications
49
What is JSX for?
Using HTML tags inside of javascript functions / classes
50
What is reconcillation in React?
- Compares differences | - Just calculates differences and updates
51
What is conditional rendering?
Check condition and return different things based on how the condition evaluates
52
What are the two phases within react?
- Render phase: Computation of differences | - Commit phase: Commit to Dom -> Lifecycle functions execution
53
What are React Hooks?
Helper function to use state or side effects in functional components
54
What are functional components?
Components declared with only using a function, not class and therefore no bindings possible
55
Which argument do you need in create react app for using typescript?
`--typescript`
56
What is the underlying function in JSX/TSX sytanxt create an HTML tag in a component?
`React.createElement()`
57
What function do you need to render a component in ReactDOM?
`ReactDOM.render()`
58
How to change states in a React component. Name two approaches?
- Hooks, use setter method from useState hook | - Class components: this.setState({...this.state, firstname:firstname})
59
What is the reconiliation in React? Explain in one sentence.
Phase to compute diff of changes in DOM for next render phase
60
What are the two phases in React Fiber?
- Render Phase: Renders all components | - Commit phase: Commits all differnces and updates DOM
61
What is the naming convention to handle events in React?
Camel case
62
What is the attribute to evoke a button click event?
onClick
63
Why do we need props? Explain in one sentence
pass/inject attributes to child components
64
What is nodejs?
- Backend server based on javascript | - Built on chromes runtime environment v8
65
What are advantages of node?
- non-blocking I/O - scalability - web-apps can act as standalone web server - large ecosystem of open source libraries
66
How do you import local and how do you import installed modules?
- `require('express')` | - `require('./local_express')`
67
What is express?
NodeJS web-application framework
68
What are characteristics of express?
- minimalistic - easy-to-use api - template engine - many middleware function
69
What is middleware?
- Function that sits between request and responses | - E.g. parsing into json, logging
70
What is express static?
Static files like HTML, images in static folder
71
Where does nodejs run client or server?
- Can be both - Server for serving html files for example - Client for getting data from external apis for example
72
How do you generate a package script
npm init
73
How do you save a module?
npm -s or yarn add
74
What does the body-parser middleware do?
Parses the body from incoming HTTP requeste
75
Is every route a middleware too
yes
76
Is every route a middleware too
yes
77
Describe authorization and authentication
- Authentication: Who am I | - Authorization: What am I allowed to do?
78
Are the following error message authentication or authorization? - Permission to URL denied to User FF - Comments are disabled for this video: - This site is marked as private by its owner - Sorry this action requires to be logged in
- Permission to URL denied to User FF: Authorization - Comments are disabled for this video: Nothing of both - This site is marked as private by its owner: Authentication / Maybe both - Sorry this action requires to be logged in: Authentication
79
What are different mechanisms for login
- Access tokens e.g. API key - Cookies - Third party like OAuth - Basic Auth
80
What is the traditional Authentication way?
- Session tokens | - Basic Auth
81
What is the modern way of Authentication?
- JWT - Encrypts user id, roles, etc into a token - Client sends it on each request
82
Why do web applications need databases
- Persist data - Structure, organize data - Keep data after restart
83
Does Authentication usually come before authorization
- Yes login before checking of access rights Proof who you are, before checking what you can do
84
What is the benefit of JWT over Session tokens?
- All information is included in JWT token - No looking up with session table - JWT expires
85
What is the canonical way of auth in node js?
Base Auth
86
Which parameters are common for a find / update monk query
identifier of object
87
Is Monk client or server
Client
88
What are some general constraints in rest
- HTTP communication protocol - Client / Server architecture - Data structure (json, xml) - Stateless - Each request all info - Cache - Responses must be cacheable - Layered System - Server can be clients
89
What are CRUD methods?
- All methods which interact with data on the web - Create - Read - Update - Delete
90
What are HTTP methods
- GET - POST - PUT - DELETE - PATH - OPTION
91
What is the difference of idempotent and safe
- Safe: Changes data | - Idempotent: If I repeat it x times is still the same happening (not return value / functionality)
92
Which methods are not idempotent?
- POST | - PATCH
93
Which methods are not safe?
- post - delete - patch - put
94
What is so special about an idempotent endpoint?
You can expect the same behavior for every call
95
Which groups of http status codes?
- 1 - informal - 2 - success - 3 - redirect - 4 - client error - 5 - server error
96
What is the key abstraction for REST?
Standardized internet protocols like HTTP / URI
97
What are query parameters appropriate for?
- To give parameter to the API - e.g. filter songs - e.g. search songs
98
How do we get Media input?
- With HTML 5 possible without further plugins | - WebRTC
99
What is the method for getting video?
`navigator.mediaDevices.getUserMedia(constraints).then(successCallback).catch(errorCallback)`
100
What are web sockets?
- Messaging protocol based on TCP | - Lightweight
101
What is the basic idea of websockets
- TCP based - Bidirectional - Full-duplex
102
What a drawbacks of websockets?
- Poor browser support - Complex handling - Massive memory consumption
103
What are strategies for infrastructure updates?
- Blue / Green - Both versions are deployed - Switch traffic on new container - Ramped - Ramping up new version
104
Pros cons of each infrastructure update strategy
- Blue / Green - Pro: Assets are available instantly - Cons: Double infrastructure needed - Ramped - Pro: less infrastructure - Con: Assets na
105
What did you learn from the rise and fall of Docker Inc?
- Think about the balance of building a successful product and make profits - Think about the developer community
106
Where should container as a service be placed in? IaaS>PaaS>FaaS>SaaS
IaaS
107
Are microservices always better than monolithic?
- Think about building your personal website with microservices - Introduce complexity and managment
108
When do you want to choose microservices architecture?
- On Problems which are already complex - Domain which can be splitt into microservice - problems where different technological solution are neccessary to reacht the goal