One line synchronous function

function somethingSync(args){ var ret; //the result-holding variable //doing something async here... somethingAsync(args,function(result){ ret = result; }); while(ret === undefined){} //wait for the result until it's available, cause the blocking return ret; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.