settimeout es6 javascript code example
Example 1: settimeout es6
// set
var timerid = setTimeout(() => {
console.log('hi :D ');
}, 1000);
// clear
clearTimeout(timerid);
// Syntax
// set
myVar = setTimeout("javascript function", milliseconds);
// clear
clearTimeout(id_of_settimeout);
/ Rnadco.ir /
Example 2: settimeout function es6
if (timerid) {
clearTimeout(timerid);
}
timerid = setTimeout(() => {
this.reqMaq(obj['fkmaqid'])
}, 2000);