OMM Flashcards

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
Q

What are different ways to ensure authentication?

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

What is Same Origin Policy?

A
  • Tried to hamper cross site scripting

- Blocks ajax requests from other origins as defined in allowed origins

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

What does asynchronous actually mean?

A

That it doesn’t block the whole program

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

What is the difference between get and post?

A
  • Post alters something, e.g. create user

- Get just gets information, e.g. get user list

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

How do you avoid SOP(Same Origin Policy) issues?

A
  • Define cross origins
    • JSON with padding
    • Reverse proxies
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

Why do we need an eventloop?

A
  • Because javascript is single threaded
    • But somehow we need to execute code “at the same time”
    • E.g. callbacks, promises, etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

What are the different event loops?

A
  • Main loop: Executes sequential code
    • Message loop: Waites for enqueued messages
    • Rendering: Calculates stylesheet, results layout, paints webpage
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

What types are in javascript?

A
  • undefined
    • number
    • string
    • boolean
    • Object
    • symbol
    • any
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

How can we check types?

A
  • Typeof

- Instanceof

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

What is typescript?

A
  • Superset of javascript

- JS with type annotations

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

Benefits of Typescript

A
  • More concise / accurate code
    • More developer control
    • Static checking
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

Why does it make sense to keep JS single threaded?

A
  • Because browser is single threaded as well

- Don’t consume too much resources of user

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

How does JS convert from int to float?

A

Point after the number

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

Explain the difference between imperative and declarative?

A
  • Imperative: Specify how to do something

- Declarative: Specify what should be done

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

Explain the MVC model

A
  • Model: Data structure / model
    • View: Everything user sees
    • Controller: How things work / Behaviour
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

What is the goal of web components?

A

Having re-usable code

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

What are the main concepts of web components?

A
  • Custom Elements
    • HTML Import
    • Templates
    • Shadow DOM
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

What are advantages of web components?

A
  • More declarative
    • More readable
    • Separation of concerns
    • Re-Usable
    • Encapsulation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

What is a polyfill?

A

Polyfill is a script which implements a workaround for things which are not implemented

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

What does the shadow DOM?

A
  • Includes DOM Elements into rendering but not in main document
    • Hides implementation details -> Encapsulatin
45
Q

Which of these are imperative and which are declarative?

A
  • HTML: Declarative
    • JavaScript: Both
    • Java: Imperative
    • SQL: Declarative
    • Typescript: Both
46
Q

What is a polyfill for?

A

Workaround for functions which are not implemented in the browser

47
Q

What is a polyfill for?

A

Workaround for functions which are not implemented in the browser

48
Q

What is React.js?

A

Javscript framework for building web applications

49
Q

What is JSX for?

A

Using HTML tags inside of javascript functions / classes

50
Q

What is reconcillation in React?

A
  • Compares differences

- Just calculates differences and updates

51
Q

What is conditional rendering?

A

Check condition and return different things based on how the condition evaluates

52
Q

What are the two phases within react?

A
  • Render phase: Computation of differences

- Commit phase: Commit to Dom -> Lifecycle functions execution

53
Q

What are React Hooks?

A

Helper function to use state or side effects in functional components

54
Q

What are functional components?

A

Components declared with only using a function, not class and therefore no bindings possible

55
Q

Which argument do you need in create react app for using typescript?

A

--typescript

56
Q

What is the underlying function in JSX/TSX sytanxt create an HTML tag in a component?

A

React.createElement()

57
Q

What function do you need to render a component in ReactDOM?

A

ReactDOM.render()

58
Q

How to change states in a React component. Name two approaches?

A
  • Hooks, use setter method from useState hook

- Class components: this.setState({…this.state, firstname:firstname})

59
Q

What is the reconiliation in React? Explain in one sentence.

A

Phase to compute diff of changes in DOM for next render phase

60
Q

What are the two phases in React Fiber?

A
  • Render Phase: Renders all components

- Commit phase: Commits all differnces and updates DOM

61
Q

What is the naming convention to handle events in React?

A

Camel case

62
Q

What is the attribute to evoke a button click event?

A

onClick

63
Q

Why do we need props? Explain in one sentence

A

pass/inject attributes to child components

64
Q

What is nodejs?

A
  • Backend server based on javascript

- Built on chromes runtime environment v8

65
Q

What are advantages of node?

A
  • non-blocking I/O
    • scalability
    • web-apps can act as standalone web server
    • large ecosystem of open source libraries
66
Q

How do you import local and how do you import installed modules?

A
  • require('express')

- require('./local_express')

67
Q

What is express?

A

NodeJS web-application framework

68
Q

What are characteristics of express?

A
  • minimalistic
    • easy-to-use api
    • template engine
    • many middleware function
69
Q

What is middleware?

A
  • Function that sits between request and responses

- E.g. parsing into json, logging

70
Q

What is express static?

A

Static files like HTML, images in static folder

71
Q

Where does nodejs run client or server?

A
  • Can be both
    • Server for serving html files for example
    • Client for getting data from external apis for example
72
Q

How do you generate a package script

A

npm init

73
Q

How do you save a module?

A

npm -s or yarn add

74
Q

What does the body-parser middleware do?

A

Parses the body from incoming HTTP requeste

75
Q

Is every route a middleware too

A

yes

76
Q

Is every route a middleware too

A

yes

77
Q

Describe authorization and authentication

A
  • Authentication: Who am I

- Authorization: What am I allowed to do?

78
Q

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

What are different mechanisms for login

A
  • Access tokens e.g. API key
    • Cookies
    • Third party like OAuth
    • Basic Auth
80
Q

What is the traditional Authentication way?

A
  • Session tokens

- Basic Auth

81
Q

What is the modern way of Authentication?

A
  • JWT
    • Encrypts user id, roles, etc into a token
    • Client sends it on each request
82
Q

Why do web applications need databases

A
  • Persist data
    • Structure, organize data
    • Keep data after restart
83
Q

Does Authentication usually come before authorization

A
  • Yes login before checking of access rights

Proof who you are, before checking what you can do

84
Q

What is the benefit of JWT over Session tokens?

A
  • All information is included in JWT token
    • No looking up with session table
    • JWT expires
85
Q

What is the canonical way of auth in node js?

A

Base Auth

86
Q

Which parameters are common for a find / update monk query

A

identifier of object

87
Q

Is Monk client or server

A

Client

88
Q

What are some general constraints in rest

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

What are CRUD methods?

A
  • All methods which interact with data on the web
    • Create
    • Read
    • Update
    • Delete
90
Q

What are HTTP methods

A
  • GET
    • POST
    • PUT
    • DELETE
    • PATH
    • OPTION
91
Q

What is the difference of idempotent and safe

A
  • Safe: Changes data

- Idempotent: If I repeat it x times is still the same happening (not return value / functionality)

92
Q

Which methods are not idempotent?

A
  • POST

- PATCH

93
Q

Which methods are not safe?

A
  • post
    • delete
    • patch
    • put
94
Q

What is so special about an idempotent endpoint?

A

You can expect the same behavior for every call

95
Q

Which groups of http status codes?

A
  • 1 - informal
    • 2 - success
    • 3 - redirect
    • 4 - client error
    • 5 - server error
96
Q

What is the key abstraction for REST?

A

Standardized internet protocols like HTTP / URI

97
Q

What are query parameters appropriate for?

A
  • To give parameter to the API
    • e.g. filter songs
    • e.g. search songs
98
Q

How do we get Media input?

A
  • With HTML 5 possible without further plugins

- WebRTC

99
Q

What is the method for getting video?

A

navigator.mediaDevices.getUserMedia(constraints).then(successCallback).catch(errorCallback)

100
Q

What are web sockets?

A
  • Messaging protocol based on TCP

- Lightweight

101
Q

What is the basic idea of websockets

A
  • TCP based
    • Bidirectional
    • Full-duplex
102
Q

What a drawbacks of websockets?

A
  • Poor browser support
    • Complex handling
    • Massive memory consumption
103
Q

What are strategies for infrastructure updates?

A
  • Blue / Green
    • Both versions are deployed
    • Switch traffic on new container
    • Ramped
      • Ramping up new version
104
Q

Pros cons of each infrastructure update strategy

A
  • Blue / Green
    • Pro: Assets are available instantly
    • Cons: Double infrastructure needed
    • Ramped
      • Pro: less infrastructure
      • Con: Assets na
105
Q

What did you learn from the rise and fall of Docker Inc?

A
  • Think about the balance of building a successful product and make profits
    • Think about the developer community
106
Q

Where should container as a service be placed in? IaaS>PaaS>FaaS>SaaS

A

IaaS

107
Q

Are microservices always better than monolithic?

A
  • Think about building your personal website with microservices
  • Introduce complexity and managment
108
Q

When do you want to choose microservices architecture?

A
  • On Problems which are already complex
  • Domain which can be splitt into microservice
  • problems where different technological solution are neccessary to reacht the goal