I need to get a value of a variable inside a setTimeout function. Doing some research I found about the callback function. Using that I do get the value but I was only able to figure out how to alert it or console log it. Now I need to assign it to a variable.
function x(callback){
setTimeout(function(){
length = text.length;
callback(length);
},100, text);
}
x(console.log.bind(console));
this console logs the length correctly. Now how do I get just the value so I could assign it to a variable?
I want the length value to be assigned to length varibale outside the function so I can operate further with it. How would I go about doing that?