Js Flashcards
Var declaration
var’s declaration is hoisted not value
== vs ===
== value
=== value and type
Const
No reassignment of value
Window.
Base global object
I frame
Window on window
Access through window.frames
Document.
HTML that is loaded on the window
Undefined
Var has no value. JS sets the value to undefined
Prototype inheritance
Object -> property
Array.prototype.newMethod = ()=>
Function declaration vs expression
Declarations are hoisted
Expressions take variable scope
Promises
Set up an a sync data retrevial
shouldComponentUpdate
Triggered from external changes
Returns true or false
Args - (nextProps, nextState)
Using ref
Ref={input => this.inputElement = input}
componentDidMount() {
if (this.props.position ===0) {
this.inputElement.focus() }
shouldComponetUpdate
shouldComponetUpdate(nextProps, nextState) {
return nextProps.persons !== this.pros.persons
Redux
Global Store -> Reducer -> Action(mapDispatchToProps) -> Dispatch -> Component
Global Store -> Triggers -> Subscription -> Component
Why is typeOf bar === ‘object’ not a good check?
Because null is also an object. Should be
typeOf bar === ‘object’ && bar !== null
If bar should be an array an ES5 check would be:
Array.isArray(bar)
S in Solid
Single Responsibility Principle - class should have one and only one reason to change, meaning that a class should have one job
O in Solid
Open Closed Principle - Objects should be open for extension, but closed for modification
L in Solid
Liskov Substitution Principle - Every sub class should be substitutable for the super class
I in Solid
Interface Segregation Principle - clients should be forced to depend on methods they do not use
D in Solid
Dependency Inversion Principle - high level must not depend on low level they should depend on abstractions.
Object.assign({}, {})
Clones object
ES6
{…state}
Box Model
Wraps every HTML element (Margin, Border, Padding, Content)
CSS Specitivity
Last In - First out
Class
ID
! Important
.filter method
array = [1, 2, 3]
newArray = array.filter( i => i !==3)
What is returned
[1, 2]
3 types React States
Local - show hide modal
Persistent - blog posts
Client - is auth