With OS X Xcode installed one can run ruby code in terminal with ">ruby somefile.rb" command (or from inside TextWrangler with the run command). You can also run a ruby interpreter from in terminal and type code in single lines while the interpreter retains variable objects.
Want same possibilities for Javascript. What must I install (if anything) on OS X to have that functionality? Not looking for an IDE as such just an interpreter that will run in Terminal.app?
I assume this is an allowed question for Stackoverflow based on other allowed questions about IDEs for various languages like: What's a good IDE for Python on Mac OS X?
In the Shortcuts app on your Mac, double-click a shortcut. In the shortcut editor, click at the top of the action list, begin typing “Run JavaScript…” in the search field, then double-click the Run JavaScript on Active Safari Tab action to add it to the shortcut editor.
It's built on Chrome's V8 JS engine which is written on C++. Node. js run a JS program directly and compiles it to machine code. Then OS execute this machine code.
To write and run a NodeJS program on mac, first download and install the LTS version of NodeJS from its official website. After installation, create a new JavaScript(. js) file, write some code inside it, and run the “node fileName. js” command in the terminal.
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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With