Javascript Flashcards
Es6
- Arrow functions
- Obj manipulation
- Spread operator
- Promises
- module import and export
- Let, const
- template literal
Var va let nad const
1.scope -var have global scope
Let and cons have blocked scope
Block lives in curly brackets.
- Hoisting- mechanism where variables and functions declarations are moved to the top of their scope before code execution
Let and const like var are hoisted to the top. Var are initialised as undefined , let and const will get reference error
Pure functions
Given the same input always return the same output
Has no side effects
Side effects
Is any application state change that is observable outside the called function other than return value
- modding any external variable
- Logging console
- writing to the screen
- tiggeing any external process
Imperative vs declarative
Imperative programs describing the specific steps used to get some results
Like for loop
Declarative- abstracts the flow control process, instead described the data flow, what to do.
Relying more on expression
Eg, map, reduce
What is a promise?
Promise is an object that may produce a single value some time in a future either resolved value or a reason that is not resolved
May be in 3 possible states: fulfilled, rejected, pending
What is the significance and what are benefits of including ‘use strict’?
Is a wY if voluntary enforce stricter parsing and error handling on your Javascript code at runtime. Code errors that would otherwise have been ignored or would have failed silently will now generate errors or throw exemptions