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
// 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; |
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
// 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 |