- Definition: Region of the program where a variable is valid.
- A variable becomes valid when it comes into scope.
- A variable remains valid until it goes out of scope.
- Variable bindings are constrained to live within a block of code where it was created.
- Blocks of code are enclosed by curly braces:
{}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const quickSort = ([pivot, ...rest]) => | |
pivot | |
? [ | |
...quickSort(rest.filter(x => x < pivot)), | |
pivot, | |
...quickSort(rest.filter(y => y >= pivot)) | |
] | |
: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const quickSort = (arr, low = 0, high = arr.length - 1) => { | |
if (low < high) { | |
const p = partition(arr, low, high) | |
quickSort(arr, low, p - 1) | |
quickSort(arr, p + 1, high) | |
} | |
} | |
const partition = (arr, low, high) => { | |
const pivot = arr[high] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Control Props | |
import * as React from 'react' | |
import warning from 'warning' | |
import {Switch} from '../switch' | |
const mergeAll = | |
(...fns) => | |
(...args) => | |
fns.forEach(fn => fn?.(...args)) |
How code splitting works in webpack?
- get the chunkIds and moreModules
- for each chunkId, if the chunk is previously cached, use that cached version
- load all the modules in moreModules
- run
__webpack_require__.e
when needed- find the head, create the script tag
- send a JSONP request, get the code
- append the script to the head
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config --global --unset http.proxy | |
git config --global --unset https.proxy | |
git config --local --unset http.proxy | |
git config --local --unset https.proxy | |
git config --global http.proxy http://127.0.0.1:8001 | |
git config --global https.proxy https://127.0.0.1:8001 |
- Heavy library but not needed initially (threejs)
- Temporal components (that come and go or are conditionally loaded): tooltips, model, notification, dialog, page scrolling
- Routes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******/ function __webpack_require__(moduleId) { | |
/******/ // Check if module is in cache | |
/******/ var cachedModule = __webpack_module_cache__[moduleId] | |
/******/ if (cachedModule !== undefined) { | |
/******/ return cachedModule.exports | |
/******/ | |
} | |
/******/ // Create a new module (and put it into the cache) | |
/******/ var module = (__webpack_module_cache__[moduleId] = { | |
/******/ // no module.id needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const states = { | |
PENDING: 'PENDING', | |
FULFILLED: 'FULFILLED', | |
REJECTED: 'REJECTED', | |
} | |
const isThenable = (thing) => thing && typeof thing.then === 'function' | |
class MyPromise { | |
_state = states.PENDING |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrderManager { | |
orders = new Set() | |
execute(command, ...args) { | |
return command.run(this.orders, ...args) | |
} | |
} | |
class Command { | |
constructor(steps) { |
NewerOlder