$ node > .help .break Sometimes you get stuck, this gets you out .clear Alias for .break .editor Enter editor mode .exit Exit the repl .help Print this help message .load Load JS from a file into the REPL session .save Save all evaluated commands in this REPL session to a file > .editor // Entering editor mode (^D to finish, ^C to cancel) let a = 2 b = a console.log(b)
2 undefined > .editor // Entering editor mode (^D to finish, ^C to cancel) 'use strict'; let a = 2 b = a console.log(b)
Thrown: SyntaxError: Identifier 'a' has already been declared > b = a 2 > .editor // Entering editor mode (^D to finish, ^C to cancel) 'use strict'
$ node Welcome to Node.js v12.18.1. Type ".help"for more information. > process.version 'v12.18.1' > os.type() 'Darwin' > os.arch() 'x64' > (To exit, press ^C again or ^D or type .exit) >
很明显的是进入命令行之后,多了
1 2
Welcome to Node.js v12.18.1. Type ".help"for more information.
$ node Welcome to Node.js v12.18.1. Type ".help"for more information. > .help .break Sometimes you get stuck, this gets you out .clear Alias for .break .editor Enter editor mode .exit Exit the repl .help Print this help message .load Load JS from a file into the REPL session .save Save all evaluated commands in this REPL session to a file
Press ^C to abort current expression, ^D to exit the repl > .editor // Entering editor mode (^D to finish, ^C to cancel) let a = 1; let b = a; console.log(b);
$ node Welcome to Node.js v12.18.1. Type ".help"for more information. > .load Failed to load: > .load /Users/durban/nodejs/test.js lethash = "83108adff87ba432cd03d15f9f82db16"; function enHash(key) { key = key instanceof Buffer ? key : new Buffer(key); var p = 16777619; // 32 var hash = 0x811C9DC5;
for (var i = 0; i < key.length; i++) { console.log(hash * p + '======' + key[i]); console.log((hash * p) ^ key[i]); hash = (hash * p) ^ key[i]; }