Document directory
- Multi-line and single-line JS Console
- Extended reading: Interpreter and Compiler
- Interactive Language
- Test in the Javascript Console
- Test in ironscheme
I recently read the construction and interpretation of computer programs (the second edition of the original book) and learned about the library Programming Language LISP dialect scheme. This non-mainstream programming language describes its interpreter in the book. Here, I want to briefly talk about the Javascript console, because it is similar to the functions of the lisp interpreter.
Multi-line and single-line JS Console
We use the global variables in the variables section in the professional JavaScript For Web developers English document as an example. The difference between local variables and global variables is a key point in JavaScript programming. The following is the sample code for global variables in this book (see the 2nd page of English version 27th ):
function test(){ msg = 'hi';}test();msg;
Firebug's JavaScript console is a powerful tool. Copy the above Code to the multi-line text box shown in, and click "run ":
The result is printed on the console. The above example prints the string "hi ".
In addition to firebug, the multi-line mode of the command line in the console also supports Web developers in the IE 8 browser. However, the IE8 developer tools are not easy to use, the reason is that only 1/3 is displayed in the result printed on the console, and the large part of 2/3 cannot be seen. In addition, you can click "run script" in the text box and then disappear for no reason.
In addition, the Javascript console of debugbar is also supported, but it needs to be used in combination with companion. js.
In the single-line mode of the command line, there is a "Developer Tools" tool in Google Chrome, And the console inside is the "clone" of safari ". The "Developer Tools" in the Opera browser are designed in a style similar to firebug, but the operation experience is a little complicated.
Extended reading: Interpreter and Compiler
Chapter 1 of "programming language: the path to practice (version 2nd)" contains the interpreter and compiler knowledge. This post is omitted.
Interactive Language
On page 1, page 2, "in an interactive language such as LISP ". Below are my notes on "interactive language:
Interactive language supports the language in which users and computer systems perform computing tasks through interactive response, also known as session language.
During the execution of a program in interactive language, you can request the user to input data and specify the next action. The user can terminate the execution of the program. After other work is completed, the program continues to be executed from the breakpoint in the program. Once the execution of the interactive language program is stopped, the system is still in the execution environment of the language, and the running program setting status (variables, assigned values, etc.) remains unchanged. Its program is generally executed in an interpreted manner. Users and programmers can input, debug, and run programs in the same environment, which makes programming and development easier. The programming environment is friendly to users, but also affects the execution efficiency of programs.
For example, programming languages such as LISP and SQL.
In practice, we will test the boring and a set of theories mentioned above.
Test in the Javascript Console
The theory cannot be without creden, so isn't it just an empty talk? OK. In the Google Chrome browser, press Ctrl, shift, and J to open "develper Tools" and enter the following in the console:
i = 5;
Run the command. The printed result is:
5
Then enter:
i
Run the command. The printed result is:
5
Test in ironscheme
Double-click ironscheme on the desktop to run the interactive console.
Enter:
(define a 3)
Do not print any results after you press Enter. Then input the following in the command line:
(define b (+ a 1))
After you press enter, no results are printed. Next, we enter the following in the command line:
echo (+ a b (* a b))
This is the value of the calculation expression. After you press enter, the following output is printed:
19