Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a javaScript engine where I can run my code without being forced to use a browser?

Is there any way to write and run a JavaScript code without having a need to run a browser and use its JavaScript engine?

Thanks!

like image 424
pencilCake Avatar asked Jun 03 '11 06:06

pencilCake


People also ask

Can JavaScript run without browser?

You can run JavaScript console in terminal or any command-line interface using Node. js, an open-source, platform-agnostic runtime that executes JavaScript outside a web browser.

Can you run JS by itself?

Within a browser, JavaScript doesn't do anything by itself. You run JavaScript from inside your HTML webpages. To call JavaScript code from within HTML, you need the <script> element.

Can you run JavaScript code without HTML?

Yes, JavaScript can be used without html. Node is another option. JavaScript was originally a web scripting language until node js was introduced.

Which engine runs JavaScript code?

V8 from Google is the most used JavaScript engine. Google Chrome and the many other Chromium-based browsers use it, as do applications built with CEF, Electron, or any other framework that embeds Chromium. Other uses include the Node. js and Deno runtime systems.


1 Answers

I am amazed no one has pointed this out yet.

Windows includes a Javascript engine that can be used from the command line.

All versions of Windows, since Windows 98, have included something called "The Windows Script Host". It's a windows-standard way to support script "engines". Since the first release, WSH supports JScript, Microsoft's version of Javascript. Among other things, this means that, from a windows command line, you can just invoke the name of any *.js file, and it will run in the JScript engine. (via either wscript.exe or cscript.exe)

You can see this question: What is the ProgId or CLSID for IE9's Javascript engine (code-named "Chakra") to learn how to invoke the higher-performance IE9 Javascript engine from cscript.exe.

I use cscript.exe to run jslint from within emacs, on any .js module I'm editing. (via flymake-for-js) Lots of people use .js modules to do system maintenance or administration.

like image 179
Cheeso Avatar answered Sep 21 '22 07:09

Cheeso