Back to list

Lodash-style Utility Functions

Lv.5542@mukitaro12 playsDec 28, 2025

Utility functions inspired by Lodash. Essential JavaScript patterns.

preview.js
JavaScript
1function debounce(func, wait) {
2 let timeout;
3 return function executedFunction(...args) {
4 const later = () => {
5 clearTimeout(timeout);
6 func(...args);
7 };
8 clearTimeout(timeout);
9 timeout = setTimeout(later, wait);
10 };
11}
12
13function throttle(func, limit) {
14 let inThrottle;
15 return function(...args) {
16 if (!inThrottle) {
17 func.apply(this, args);
18 inThrottle = true;
19 setTimeout(() => inThrottle = false, limit);
20 }
21 };
22}
23
24function deepClone(obj) {
25 return JSON.parse(JSON.stringify(obj));
26}

Custom problems are not included in rankings