As a web developer, it is important to understand the sequence of JS execution, the principle of parsing, otherwise it will not be able to control the small and useful language
JavaScript is a language that implements the dynamic effects of a Web page, and is primarily responsible for interacting with the server, discarding the constraints of classes like Java, simplifying the data structure, and using the TypeOf operator to get only number,string,boolean,underfined , Null,function,object, return simple, then say the JS execution sequence
JS is a block (code block) execution of the 1> the browser parses the HTML when parsing JS, like the first to download JS into the browser memory (XML-like DOM parsing, note: XML is parsed into the computer memory)
2> Enter code block one
3> Grammar detection: Do parsing, if there are errors, you cannot load the page (parenthesis mismatch, write wrong semicolon) (syntax error), similar to the compilation error in Java (into the next block of code)
4>. Preprocessing: Preprocessing the var variable and function in the JS block, at which point the variables and function in JS are declared, but are not assigned, similar to the loading into the method area in Java
5> Execute code block with Run error (variable not declared, etc.), execution completed into next code block execution
Also under alert () This method, alert () is a blocking method that interrupts the program, blocks all threads, JS is single-threaded, starts the execution queue to execute the method,
Article reference: (which contains declarative functions and variable-type functions to perform chunked behavior) http://www.admin10000.com/document/3752.html
Summary of JavaScript execution sequence