One thing that is worth mention is that callback hell can be avoided even if you are "stuck" in an environment that doesn't support promises or async/await. You can always use a function reference instead of an anonymous function.
The game example could look like this:
// ...varlevelThreeReached=function(value){console.log('Level Three reached! New score is '+value);}functionlevelTwoReached(value){console.log('Level Two reached! New score is '+value);levelThree(value,levelThreeReached);}functionlevelOneReached(value){console.log('Level One reached! New score is '+value);levelTwo(value,levelTwoReached);}functionstartGame(){varcurrentScore=5;console.log('Game Started! Current score is '+currentScore);levelOne(currentScore,levelOneReached);}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice article. Good job.
One thing that is worth mention is that callback hell can be avoided even if you are "stuck" in an environment that doesn't support promises or async/await. You can always use a function reference instead of an anonymous function.
The game example could look like this: