Skip to content

Instantly share code, notes, and snippets.

View rootTheLure's full-sized avatar

Dzmitry Herasimov rootTheLure

View GitHub Profile
// 1) Simple cache class with limited size
const c = new Cache(3); // 3 is maximum length of cache
// add(key, value), key any type, value any type;
c.add('one', 1);
c.add('two', { a: 2 });
c.add('three', '3');
c.get('one'); // -> 1
c.add('four', 4);
c.get('one'); // -> undefined
// 1) what is console output for every line below
typeof 5;
typeof new Number();
typeof 0;
typeof -0;
typeof null;
typeof undefined;
typeof NaN;
typeof !0+1;
typeof Object;