JavaScript Shell and More

This topic was published by and viewed 1789 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author

  • DevynCJohnson
    • Topics - 437
    • @devyncjohnson

    As many computer users know, a variety of scripting languages exist. Such scripting languages can be run in executable files called scripts. Commonly executed scripts may be written in Python, Ruby, Perl, BASH (shell), etc. Also, these same languages have interactive interpreters that allow users to type a command and execute it immediately. However, JavaScript is a popular scripting language that appears to only run in a web-browser as part of the webpage. Perhaps, JavaScript is no different than the other previously mentioned languages.

    "jsc" is a command-line tool that allows users to execute a JavaScript as if it were any other type of script. Open a terminal and type "jsc" and then the path to the JavaScript file. If no file or path is specified, then an interactive JavaScript shell is seen. Type a JavaScript command at the prompt and press enter to see the results. This utility provides developers a way to test small amounts of code in a terminal. Also, JavaScript programmers are not restricted to web development.

    jsc Shell
    jsc Shell

    "rhino" is just like jsc, but it provides more features and abilities. To execute a JavaScript file using rhino (via command-line), type rhino -e FILEPATH. When typing "rhino" without parameters, a prompt will appear; this is the JavaScript interactive shell.

    NOTE: jsc is similar to WebKit while rhino is related to Gecko.

    JavaScript can also be transpiled. Transpilation is the process of converting one programming language to another. For instance, with the command-line utility "rhino-jsc", developers can convert JavaScript into Java class files (*.class). This further helps developers to use their JavaScript programming skills for uses not related to the web.

    JavaScript can also be transpiled to and from a variety of languages. The below list is not a complete list of transpilers.

    "Node.js" ( is a cross-platform runtime environment that runs on a server. Server admins can use Node.js on their server instead of HTML, HTTP, and web servers. Node.js processes JavaScript code and then sends the results/output to the client.

    Once users are using a JavaScript shell, they could use npm to install "shelljs" ( which provides portable Unix commands in JavaScript.

    Node Package Manager (npm) ( is a lot like the "pip" command used by Python programmers to install more Python packages. npm is also similar to the "pear" command used by PHP developers for the same purpose. The general format for the npm command in a terminal is npm install MODULE.

    Considering that JavaScript is a script that can run inside or outside a web-browser, many users may wonder about a hashpling. Well, JavaScript files do not require or typically use a hashpling/shebang. However, some systems may support "#!/usr/bin/env node". Alternately, polyglot hashplings can be made. This requires the file itself being a shell script that initiates rhino or jsc to interpret the JavaScript code that is in the shell script. In addition, users could make a custom hashpling. For instance, in the first line of your JavaScript files, add this line "#!/usr/bin/env jsc" or "#!/usr/bin/env rhino".

    Various other JavaScript consoles and shell are available as seen in this list -

    Further Reading

Viewing 1 post (of 1 total)