- What are JS primitive data types?
- What's the use of
Symbol
? - Have you used
BigInt
?
- What's the use of
- Tell me about
prototype chain
. - How do you implement a virtualized list? solution
Map
vs plain object? MDN solution- flexbox
- How to narrow a variable's type in typescript?
Programming
Curry
Implement the following function
// add(5, 2) 7
// add(5)(2) 7
function curry(func) {
return function curried(...args) {
if (args.length >= func.length) {
return Reflect.apply(func, undefined, args);
} else if (args.length < func.length) {
return (...a) => curried(...args, ...a);
}
};
}
function add(a, b) {
return a + b;
}
const curriedAdd = curry(add);
console.log(curriedAdd(2)(5)); // 7
console.log(curriedAdd(2, 5)); // 7
Sort
Sort an array, even number on the left (in descending order), odd number on the right (in ascending order) and 0 in the middle.
// [1,4,5,2,7,0] => [4,2,0,1,5,7]