try / catch

  • Sometimes operations fail
  • It would be nice to be able to handle errors gracefully
  • Errors immediately exit the current function and keep bubbling up until something catches them
  • try / catch in JavaScript lets you do this
  • You can catch an error and handle it

6 / 23