I've recently found this code snippet:
function start() {
function sleep(milliSeconds) {
var startTime = new Date().getTime();
while (new Date().getTime() < startTime + milliSeconds);
}
sleep(10000);
return "Hello Start";
}
What advantages do we have defining functions this way instead of using a 'traditional' approach?
Thanks in advance.
traditional approach? One function inside another simply works in a different scope.