Make sure you understand the order of how scripts are processed and how statement are executed to be able to better pinpoint problems. remember that JS processes code line by line
Execution Contexts:
statements in a script exist in either,
These contexts have a scope, either a global scope(a variable outside of a function or a variable not lead with “var”) or function-level(variable only working within function). As script enters a new context two things happen.
prepare- new scope, variables, functions and arguments are created execute - script can now assign values to variable, call functions to run, and execute statements
To understand scope know that each execution context posesses it’s own variables objection holding functions parameters and variables withing it and parent variables object is accessible as well.
To understand errors know that JS will deploy an exception which the interpreter stops to look for a handling code for.
When dealing with an error you can find it written in the script. Handle the error gracefully using statements:
Dubugging Workflow
what is the problem
CHROME DEV TOOLS