return in a setTimeout function code example
Example 1: settimeout function
setTimeout(function(){
$('#overlay'). modal('hide')
}, 5000);
Example 2: js after settimeout
function doHomeWork(subject, callback){
setTimeout(callback,500);
console.log("doing my homework:", subject)
}
doHomeWork("Maths", function(){console.log("finished my homework");});
Example 3: javascript this in settimeout
function func() {
this.var = 5;
this.changeVar = function() {
setTimeout(() => {
this.var = 10;
}, 1000);
}
}
var a = new func();
a.changeVar();