How do I get a Javascript runtime interpreter installed on OS X?
Node.js. It's the V8 engine + libraries + REPL.
Although Node is usually used for web/network-related applications, at its core it's just a plain JS engine and can even be used for shell scripting.
You can install it from the installer, brew
or just ./configure && make
from a Node.js' tarball.
There's also Rhino.
v8. Its the javascript engine used in google chrome. You have to compile it for mac OS X, though. Theres a good tutorial here.
You have two options:
Use console in your Browser: Browsers such as chrome,safari, firefox come buildtin with console which are cappable of running javascript. to open open console on chrome. Press CTRL + SHIFT + J
Install Nodejs: As others have pointed out, try http://nodejs.org/ using which you can run javascript in terminal app similar to irb
There is a Javascript interpreter in the JavaScriptCore framework that comes with OS X. The interpreter is called jsc and can be found at the following path:
/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers/jsc
There is a built-in function, quit()
, which will exit interactive mode.
If you want to make it easier to use I suggest creating a symlink to a location in your path, e.g.:
sudo ln -s /System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers/jsc /usr/local/bin
This will put a symbolic link in /usr/local/bin
.