Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interpreting JavaScript outside of the browser?

This is more out of curiosity that a real requirement, but I'm wondering if it's possible to treat JavaScript as (ideally) a first-class .NET citizen, or (secondarily) have some way of invoking/interpreting pure JavaScript functions (that don't require the DOM) in a desktop setting?

Has anyone ever attempted implementing a CLR version of JavaScript? Something tugs at the back of my mind concerning this, but now that I think about it it was probably PHP, not JavaScript.

like image 219
devios1 Avatar asked Mar 15 '09 21:03

devios1


People also ask

Can JavaScript run outside of 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.

Is JavaScript interpreted by the browser?

The source code is passed through a program called a compiler, which translates it into bytecode that the machine understands and can execute. In contrast, JavaScript has no compilation step. Instead, an interpreter in the browser reads over the JavaScript code, interprets each line, and runs it.

How JavaScript works under the hood?

js uses Google's V8 engine to provide JavaScript runtime and employes its own event loop using the libuv library (written in c). Node follows the same callback approach like Web APIs and works in a similar fashion as the browser.

Can we use JS 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.


1 Answers

For your second option, there's Rhino and things like it.

like image 77
MarkusQ Avatar answered Nov 03 '22 00:11

MarkusQ