reading-notes

Memory Storage

JS Call Stack

Understanding the JavaScript Call Stack

  1. “call” is the invocation of a function
  2. only 1 call can happen at once
  3. Last In, First Out
  4. Im not drawing
  5. What causes a stack overflow? A stack overflow occurs when there is a recursive function (a function that calls itself) without an exit point. The browser (hosting environment) has a maximum stack call that it can accomodate before throwing a stack error.

JS Message Errors

JavaScript error messages

  1. Reference errors

This is as simple as when you try to use a variable that is not yet declared you get this type os errors. This is also a common thing when using const and let, they are hoisted like var and function but there is a time between the hoisting and being declared so when you try to access them a reference error occurs, the fact that this happens to let and const is called Temporal Dead Zone (TDZ).

  1. Syntax errors: this occurs when you have something that cannot be parsed in terms of syntax, like when you try to parse an invalid object using JSON.parse.
  2. Range errors Try to manipulate an object with some kind of length and give it an invalid length and this kind of errors will show up. An array for instance cannot have a negative length

  3. Type errors

Like the name indicates, this types of errors show up when the types (number, string and so on) you are trying to use or access are incompatible, like accessing a property in an undefined type of variable.

  1. Breakpoints make your code stop at a set point

  2. putting “debugger” in your code works just like a breakpoint.