Skip to content

Instantly share code, notes, and snippets.

View bishil06's full-sized avatar
🏠
Working from home

bishil06 bishil06

🏠
Working from home
View GitHub Profile

Cheat sheet: JavaScript Array methods

Deriving a new Array from an existing Array:

['β– ','●','β–²'].slice(1, 3)          ⟼ ['●','β–²']
['β– ','●','β– '].filter(x => x==='β– ') ⟼ ['β– ','β– ']
    ['β–²','●'].map(x => x+x)        ⟼ ['β–²β–²','●●']
    ['β–²','●'].flatMap(x => [x,x])  ⟼ ['β–²','β–²','●','●']
@branneman
branneman / better-nodejs-require-paths.md
Last active June 24, 2025 22:40
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions