Skip to content

Instantly share code, notes, and snippets.

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

Osman Nuri Okumuş onokumus

🏠
Working from home
View GitHub Profile
@tbranyen
tbranyen / events.js
Last active May 10, 2024 14:54
Rethinking events using ES6 (https://tbranyen.com/events)
const bus = {};
const get = e => (bus[e] = bus[e] || new Set());
export const listeners = new Proxy(bus, { get });
export const emit = (e, ...args) => listeners[e].forEach(fn => fn(...args));
@jonschlinkert
jonschlinkert / longest.js
Created June 13, 2018 14:49
Get the length of the longest item in an array of strings.
const longest = arr => arr.reduce((len, v) => Math.max(v.length, len), 0);
@remarkablemark
remarkablemark / README.md
Last active June 8, 2024 21:48
Classes - ES5 vs ES6

JavaScript Classes - ES5 vs ES6

An example that shows the difference between creating a JavaScript class and subclass in ES5 and ES6.

Reference

// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}