原谅菜鸟的问题,但为什么我不能(几乎)从coffee
REPL(或者从在 TextMate 中编写和运行的文件)调用任何标准函数?
变量赋值有效,函数无效。
例子:
coffee> string = "string"
'string'
coffee> list = [1,2,3]
[ 1, 2, 3 ]
coffee> num = 42
42
coffee> opposite = true
true
coffee> num = -42 if opposite
-42
但
coffee> alert "Hello, World"
ReferenceError: alert is not defined
at repl:1:5
at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:33:28)
at repl.js:239:12
at Interface.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:62:9)
at Interface.EventEmitter.emit (events.js:117:20)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:117:20)
和
coffee> print "Hello"
ReferenceError: print is not defined
at repl:1:5
at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:33:28)
at repl.js:239:12
at Interface.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:62:9)
at Interface.EventEmitter.emit (events.js:117:20)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:117:20)
真正让我感动的是:
coffee> console.log "Help!"
Help!
undefined
我通过 Homebrew 安装了 Node,并通过npm
.