Posts tagged Javascript

How to run Javascript code on Mac OS X

When developing Javascript, you may wish to run code outside the browser. Luckily OS X comes with a world-class Javascript engine, which features a command-line interpreter.

Since it’s hidden deep inside a framework, create a symbolic link:

sudo ln -s /System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc /usr/local/bin/js

Now, you can enter the interpreter by simply typing:

js

The interpreter can be quit by typing quit(); or ctrl+c.

Toggling two code blocks

Often when debugging code, you toggle between two blocks of code. You comment in one block, and comment out the other block. As simple as it sounds, going back and forth dozens of times can become quite annoying.

more...