Javascript Callback Hell
Javascript Callback Hell Table of Contents callback hell Promise bluebird 1 callback hell Javascript callback hell looks like an inherent problem in js language, because of its asynchronous nature, writing callback functions and nesting them together looks the only way to coding for a newbie. It then gave programmers some mess code, if he persists to writing nesting callback code, and this mess codes are named as callback hell . fs.readFile( "file.json" , function ( err , val ) { if ( err ) { console.error( "unable to read file" ); } else { try { val = JSON.parse(val); console.log(val.success); } catch ( e ) { console.error( "invalid json in file" ); } } }); 2 Promise Promise is a new ES6(ECMAScript 2015) feature, is used for deferred and asynchronous computations. Promise is also a proposal , which represents the eventual ...