REPL Terminal
REPL (Read Eval Print Loop)
Window command, UNIX/LINUX Shell ์ฒ๋ผ ์ฌ์ฉ์๊ฐ command๋ฅผ ์ ๋ ฅํ๋ฉด system์ด ๊ฐ์ ๋ฐํํ๋ ํ๊ฒฝ์ ๊ฐ๋ฆฌํด
Node.js๋ REPL ํ๊ฒฝ๊ณผ ํจ๊ป ์ ๊ณต๋๋ฉฐ, ๋ค์๊ณผ ๊ฐ์ ๊ธฐ๋ฅ์ ์ํ ํ ์ ์๋ค
Read
: User์ ๊ฐ์ ์ ๋ ฅ ๋ฐ์ JavaScript data ๊ตฌ์กฐ๋ก memory์ ์ ์ฅํจ
Eval
: ๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌ (Evaluate) ํจ
Print
: ๊ฒฐ๊ณผ๊ฐ์ ์ถ๋ ฅํจ
Loop
: Read, Eval, Print๋ฅผ ์ ์ ๊ฐ
ctrl + c
๋ฅผ ๋ ๋ฒ ๋๋ฌ ์ข ๋ฃํ ๋ ๊น์ง ๋ฐ๋ณตํจ
Node.js์ REPL ํ๊ฒฝ์ JavaScript code๋ฅผ testing & debugging ํ ๋ ์ ์ฉํ๊ฒ ์ฌ์ฉ๋จ!
Starting REPL
REPL์ Shell / Console์ parameter ์์ด node๋ฅผ ์คํํ์ฌ ์์ํ ์ ์์
1. ๊ฐ๋จํ ํํ์ ์ฌ์ฉ
2. ๋ณ์ ์ฌ์ฉ
๋ค๋ฅธ script ์ฒ๋ผ, ๋ณ์์ ๊ฐ์ ์ ์ฅํ๊ณ ๋์ค์ ๋ค์ ์ถ๋ ฅ ํ ์ ์์
var
keyword๋ฅผ ์ฌ์ฉํ๋ฉด๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํ์ ๋ ๋ณ์์ ๊ฐ์ด ์ถ๋ ฅ๋์ง ์๊ณ ,
var
keyword๋ฅผ ์ฌ์ฉํ์ง ์์ผ๋ฉด๋ณ์์ ๊ฐ์ด ์ถ๋ ฅ ๋จ
**console.log()**๋ฅผ ํตํด ์ถ๋ ฅ ํ ์ ์์
3. Multi-line Expression ์ฌ์ฉ
do-while loop REPL์์ ์คํํด๋ณด๊ธฐ!
Underscore(_) Variable
Underscore variable์ ์ต๊ทผ ๊ฒฐ๊ณผ๊ฐ์ ์ง์นญํจ!
REPL Commands
ctrl + c
: terminate the current command
ctrl + c
2๋ฒ: terminate the Node REPL
ctrl + d
: terminate the Node REPL.
์/์๋ ํค
: see command history and modify previous commands
Tab
: list of current commands
.help
: list of all commands
.break
: exit from multiline expression
.clear
: exit from multiline expression
.save [filename]
: save the current Node REPL session to a file
.load [filename]
: load file content in current Node REPL session
Stopping REPL
As mentioned above, use ctrl + c twice to come out of Node.js REPL
Last updated
Was this helpful?