rika's notebooks

  • Node Callback vs Promise vs Await - /rika/node-callback-vs-promise-vs-await
    Last edited 6 years ago
    const ERR = null; // const ERR = new Error('test error'); // --------------------------------------------------------------- // 0. Synchronous function // --------------------------------------------------------------- function synchronousFunction(param) { if (ERR) { throw ERR; } console.log(`synchronousFunction: ${param}`); return param; } try { var result = synchronousFunction('0') console.log(`synchronousFunction:result: ${result}`); } catch(err) { console.log(`synchronousFunction:err: ${err}`); }