Skip to content

Instantly share code, notes, and snippets.

View chrisryana's full-sized avatar
🐢
медленно но верно иду к цели

Chris Ryana chrisryana

🐢
медленно но верно иду к цели
  • Kashira, Moscow region
View GitHub Profile
@chrisryana
chrisryana / usefull.js
Last active March 12, 2024 13:38
Полезные функции на чистом js
// Пример зачем нужен throttle https://webdevkin.ru/posts/frontend/kak-ispolzovat-throttle-i-debounce
function throttle(fn, ms) {
let lastTime;
return function throttled() {
let timeSinceLastExecution = Date.now() - lastTime;
if(!lastTime || (timeSinceLastExecution >= ms)) {
fn.apply(this, arguments);
lastTime = Date.now();
}
};