Don't Be Afraid of the JavaScript Stack Trace

Don't Be Afraid of the JavaScript Stack Trace

At some point, your code will not work. You could spend hours trying to google for a solution. Instead, use the JavaScript stack trace to find the problem. A beginner-friendly overview of the JavaScript stack trace and tips on how to use it.

Da526e4b5901b3a2759cf234285c6488?s=128

Jennifer Bland

March 08, 2019
Tweet

Transcript

  1. 3.

    3 Truths 1 Lie • I saw the only Gold

    Medal won by
 Great Britain • I saw the only medal won by Mongolia • I was an Olympic Torch Runner • I attended the Opening Ceremony
  2. 6.

    Heap • mostly unstructured region of memory • memory allocation

    to variables and objects happen here • finite in size
  3. 7.

    Queue • list of messages to be processed and the

    associated callback functions to execute • messages executed by call stack • message processing ends with stack is empty
  4. 8.

    What is the Stack Trace? • what functions were called

    • in what order • from which line and file • with what arguments
  5. 11.
  6. 12.
  7. 13.
  8. 14.
  9. 15.

    console.table() • display objects as a table • click on

    headers to sort • works with objects of objects
  10. 17.
  11. 18.

    Why use console.trace() • easier than writing a series of

    console.log • remember to remove only one line for production • shows file where it was called • shows line number where it was called
  12. 21.

    window.onerror() window.onerror = function(message, file, line, col, error) { //

    send crash information back to your servers console.log(error.stack); }
  13. 23.

    3 Truths 1 Lie • I saw the only Gold

    Medal won by
 Great Britain • I saw the only medal won by Mongolia • I was an Olympic Torch Runner • I attended the Opening Ceremony