Front End Flashcards
What are synthetic events
Synthetic events combine the response of different browser’s native events into one API, ensuring that the events are consistent across different browsers.
React features
Jsx
Community
High performance
Virtual dom
One way data binding
What is virtual dom
React keeps a lightweight representation of the real DOM in the memory, and that is known as the virtual DOM. When the state of an object changes, the virtual DOM changes only that object in the real DOM
Difference ES5 and ES6
Imports
What is an event
action that a user or system may trigger, such as pressing a key, a mouse click, etc.
Why are keys necessary for lists
To find components on virtual dom and only replace them
Arrow functions difference to normal functions
It is unnecessary to bind ‘this’ inside the constructor when using an arrow function. This prevents bugs caused by the use of ‘this’ in React callbacks.
what are data structures
how to save and organize data
files structure vs data structure
files are save on disk, data on RAM or disk. File has low compatibility with other applications
what are linked lists
structure that has nodes that are connected to each other forming a chain
ways of searching in structures
lineal: iterating through it
binary: separate into chunks, then perform a search
what are hooks
specific react functions that allow you to use things like state, lifecycle events etc. in functional components
limitations of react
high learning curve
low structure and much freedom make projects look different
what is dangerouslySetInnerHTML
allows to dangerously add html that is not checked by React and may allow injection of malicious code
React lazy
allow the use of components that don’t end up in the bundle. They are fetched when they want to be used and a fallback is shown. Lodable library adds suspense to it to make it easier to use
How to optimize performance
React.lazy
React.memo
Fragments instead of divs
State and form libraries to improve rerendes
What is reconciliation
react updates dom when value changes
what are higher-order component (HOC)
Injects reusable logic in a component like styling, props, loading behavior etc.
What is a closure?
Closure is a function in a function. The inner function has access to the outer’s function scope and parameters even after the outer function has returned.
What are the differences between call, apply, and bind?
call and apply immediately calls a function while bind creates a new function that can be invoked in the future. Arguments with call are passed in one by one, separated with a comma while apply expects an array as its argument.
What is currying function
separating a function with many arguments into many function with one argument to make code more readable
What is memoization?
Memoization is an optimization technique by storing the result of expensive function calls and returning the cached results when the same inputs occur again.
What is a higher-order function?
a higher-order function is a function that accepts another function as an argument or returns a function as a return value or both of them.
Map, filter and reduce are some examples of higher-order functions that are already built-in to JavaScript.
what is css box model
The box model is a box that wraps around every HTML element.
The box contains content, padding, border, and margin.
what is css sprite
CSS sprites combine multiple images into one single larger image. This would only require one server request resulting in a faster loading time.
visibility hidden versus display none
visibility: hidden hides the element, but it occupies space and affects the layout of the document.
display: none also hides the element but not occupy space. It will not affect the layout of the document.
ways of positioning
static
relative
absolute
fixed: relative to view port and don’t move on scrolling
sticky
difference inline, block and inline-block
Block elements always start on a new line. They will also take space of an entire row.
Inline elements don’t start on a new line, These elements appear on the same line with the content and tags beside them.
Inline-block elements are similar to inline elements, except they can have padding and margins added on all four sides.
pseudo-elements
A pseudo-element allows you to manipulate parts of an element in a special way like :after
pseudo:class
:hover
HTML Entities
starts with & and finish with ;
Used for things like special characters
seesion storage vs local storage
session storage is deleted after browser is closed
difference of id and class
id can only be one. class can be many
how does binary search works
get a sorted array
split in the middle
take a sample
is sample is smaller, check the other half. if not, take this half
continue until you find
like looking wor a word in a dictionary
what is a queue
a list of elements added after each other
what is a binary tree
a tree data structure with two nodes after each node
difference between throttle and debounce
throttle fires values periodically, debounce only until it end getting values and the period of time passed