const language = {
name: 'JavaScript',
author: 'Brendan Eich'
};
// Inheriting from another object.
Object.setPrototypeOf(language, {createdAt: "Netscape"});
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
var data = x ? y ? z ? z : y : x : 0; | |
// I call this the "if..if" pattern, and it's BAD. It means: | |
var data; | |
if (x) { | |
if (y) { | |
if (z) { | |
data = z; | |
} |
While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.
Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.
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
/** | |
* Sort array of objects based on another array | |
*/ | |
function mapOrder (array, order, key) { | |
array.sort( function (a, b) { | |
var A = a[key], B = b[key]; | |