Im newbie in nodejs, so I have a simple problem, but can't solve it.
For example, I have func like this:
var func = function(){
setTimeout(function(){
return 5;
}, 1000);
};
when I call func i got 'undefined'. I understand why, but I can't understand how I can change my function for returning 5 instead of undefined.
I can rewrite func with callback argument, and call callback from setTimeout, but I want to return result from function without using callbacks.
In V8 we have generators and keyword 'yield', I think it maybe help me,so can anyone explain how it works and how to use it in this example. Thanks.