//run this in your console
for (var i = 0; i <= 3; i++) {
setTimeout(function(){
console.log(i);
}, 0);
}
This file contains hidden or 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
| // this function takes in any parameter and can tell if it's "falsy" or not. | |
| // falsy means it's either false, 0, null, undefined, NaN, or an empty string/array/object | |
| // see the test cases at the bottom for a clearer picture | |
| function isFalsy(item) { | |
| try { | |
| if ( | |
| !item // handles most, like false, 0, null, etc | |
| || ( | |
| typeof item == "object" && ( |
This file contains hidden or 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* cycleThruFnArgs(obj, fnArr) { | |
| while (fnArr.length > 0) { | |
| yield fnArr.shift().call(obj); | |
| } | |
| } | |
| function callAll(obj, args) { | |
| if (arguments.length < 2) throw 'Supply obj and args array'; | |
| var gen = cycleThruFnArgs(obj, args); |
Minimizing lookup times is a central problem in data management, particularly for large applications. Linear lookup time is bad. Sublinear lookup time is better. Constant lookup is ideal.
Client-side, in the context of a Redux-managed application, the problem becomes a matter of defining the shape of app state.
This article explores two avenues for better organizing such front-end state:
(1) serializing data from the back end, reducing to fully-indexed state shape via utility reducers, and
(2) caching data on the front end, in particular by utilizing the Reselect library in React-Redux mapStateToProps functions to create or look up "memos" of chunks of derivable data.
OlderNewer