reading-notes

Class 301.10

Notes

Readings

Understanding the JavaScript Call Stack

  1. What is a ‘call’?

    a function being invoked

  2. How many ‘calls’ can happen at once?

    single-threaded engine means only one at a time

  3. What does LIFO mean?

    Last In, First Out

  4. Draw an example of a call stack and the functions that would need to be invoked to generate that call stack.
    function a() {  b();}
    function b() {  c();}
    function c() {  // Some code here }
    a(); // Start here
    

    output: ``` c() <- Top of the stack (currently executing) b() <- Called by ‘a’ a() <- Called first, at the bottom of the stack ———– main() <- Main entry point of the program ```

  5. What causes a Stack Overflow?

    when too many calls get made to the stack (typically recursion or other runaway functions)

JavaScript error messages

  1. What is a ‘reference error’?

    A “Reference Error” is thrown in JavaScript when you try to use a variable that has not been declared. It means that the referred variable is not in scope at the point in the code where it’s being referenced.

  2. What is a ‘syntax error’?

    A “Syntax Error” occurs when the structure of the code violates the grammatical rules of the programming language. In JavaScript, this could be a missing parenthesis, bracket, or misuse of an operator, leading to code that the interpreter cannot understand.

  3. What is a ‘range error’?

    A “Range Error” is thrown when a value is outside the set or allowable range of values as defined by the operation or the array. For example, in JavaScript, this error can occur when you try to create an array with a negative length.

  4. What is a ‘type error’?

    A “Type Error” is thrown when an operation is performed on a value of an unexpected type. For example, trying to call something that is not a function or accessing a property on undefined or null in JavaScript will result in a type error.

  5. What is a breakpoint?

    A “breakpoint” is a debugging tool used in many development environments. It’s a mark in the code where the execution will be paused when debugging. This allows developers to inspect the current state of the program at that specific point in the execution flow.

  6. What does the word ‘debugger’ do in your code?

    The debugger keyword in JavaScript is used to pause the execution of code and initiate debugging mode if the debugging tool is available. When the JavaScript engine encounters the debugger statement, it stops execution at that point, allowing developers to step through the code and inspect variables, call stack, and other details within the debugging tool.

Things I want to learn more about

References