View on GitHub

reading-notes

Daily Reading 10

In Memory Storage

Understanding the JavaScript Call Stack

What is a ‘call’?

A request to execute a function in full.

How many ‘calls’ can happen at once?

One. All tasks must be completed in order, so they are performed one at a time.

What does LIFO mean?

Last In, First Out. When a stack is created (by having nested functions) the last thing called is the first action executed. The deepest nested item is the first one to take effect.

Draw an example of a call stack and the functions that would need to be invoked to generate that call stack.

function nonNested(){

function nested(){ do thing };

};

nonNested();


|nested| |nonNested_| |__| |__| |____|

What causes a Stack Overflow?

Too many things placed into a stack. By having a hard limit that crashes the program when hit, infinite loops or infinite recursion is prevented.

JavaScript error messages

What is a ‘reference error’?

Trying to call a function that doesn’t exist yet. (Did you define it lower down in the program?)

What is a ‘syntax error’?

You formatted it wrong. Maybe you misspelled something, or forgot a curly brace, or named something different last time you referred to it.

What is a ‘range error’?

Do a length manipulation with an invalid value for length. Such as trying to create an array with a negative length value.

What is a ‘type error’?

Wrong data format. Dividing an object? Multiplying a string? 2 plus false equals Type Error.

What is a breakpoint?

A breakpoint is used for debugging, and is a point that your code will freeze, and allow you to look at relevant values and the overall state of your code at the time of the breakpoint, to better help you diagnose and solve errors.

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

A debugger is a tool in most IDEs that in general, help you figure out what is wrong with your code and what actions need to be taken to solve it by providing you with lots of diagnostic information, and logic step by step capability to figure out the precise moment of failure.

Back To Main Page.