Skip to content

Instantly share code, notes, and snippets.

View sabir-jamia's full-sized avatar
🎯
Focusing

Mohammad Sabir sabir-jamia

🎯
Focusing
View GitHub Profile
@pajaydev
pajaydev / js-objects-compare.md
Last active April 5, 2024 01:47
JS Objects : Object.keys vs for..in vs getOwnPropertyNames vs Object.entries

Object.keys vs for..in vs getOwnPropertyNames vs Object.entries

const language = {
  name: 'JavaScript',
  author: 'Brendan Eich'
};

// Inheriting from another object.
Object.setPrototypeOf(language, {createdAt: "Netscape"});
@getify
getify / 1.js
Last active September 17, 2020 22:45
Nested ternary: good vs bad
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;
}

Folder Structure

Please note

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.

@ecarter
ecarter / mapOrder.js
Created December 2, 2011 15:40
Order an array of objects based on another array order
/**
* 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];
@lancejpollard
lancejpollard / node-folder-structure-options.md
Created November 28, 2011 01:50
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin