How To Avoid Javascript Bugs

Mainasara πŸ‡³πŸ‡¬ on April 04, 2019

Being a javascript programmer is great but we can never avoid the dreaded stack trace! 😑, most of these bugs are just one Google search away from... [Read Full]
markdown guide
 

Correct usage.

let laterUsed;

doAsyncTask().then(()=>{
    useVariable(laterUsed || externalAlternativeValue); 
    // βœ… Another value is used when the original value is undefined
})

hmmm ...

Even More Correct Usage

doAsyncTask()
  .then(result => {
    useVariable(laterUsed)
  })
  .catch(e => {
    // handle whatever happens when doAsyncTask() goes wrong
  })

If you're trying to avoid bugs in JavaScript, I'd really recommend

  • not communicating between asynchronous processes using global variables.
  • not using undefined to indicate an error state. Or an absence of value.

πŸ˜„

 
 
code of conduct - report abuse