How do you run JavaScript script through the Terminal?

BLUC picture BLUC · Dec 16, 2011 · Viewed 454.9k times · Source

For instance, if you were to run a Python script you would type python filename.py or if you wanted to run a C program make filename then ./ filename. How do you do this with .js files?

Answer

Ionică Bizău picture Ionică Bizău · May 26, 2013

Another answer would be the NodeJS!

Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

Using terminal you will be able to start it using node command.

$ node
> 2 + 4
6
> 

Note: If you want to exit just type