debounce and throutel
Example heading with h2 size
Example heading with h3 size
Following is sample java code.
function debounce(cb, delay){
let counter;
return (...args)=>{
const context = this;
clearTimeout(counter)
counter = setTimeout(cb.apply(this, args), delay);
}
}
function throttle(fun, delay){
let throttleIng = false;
return (...args) => {
const context = this;
if(!throttleIng) {
throttleIng = true;
fun.apply(this, args)
setTimeout(()=>{
throttleIng = false;
}, delay)
}
}
}
document.addEventListener('scroll', debounce(() => {
// Handle the scroll event
}, 100));
// const arr= ["ramu","yogesh",["javscrip"]]
// console.log(String(arr).split(','))
// // const combine = arr.reduce((item, acc)=>{
// // acc.name = item
// // return acc;
// // }, {})