How can I execute JavaScript at the command prompt?

JavascriptWeb DevelopmentFront End Technology

Java SE 8 came with a new engine called Nashorn, which is based on JSR 292. It provides compliance with the ECMA normalized JavaScript.

You can run JavaScript programs from the command line using Nashorn. Include a command-line tool called jjs. The bin folder of a JDK installation has it, with other tools like jar.

Here’s the js file new.js

var display = function() {
   // print “Hello World!” here

Run it on a command prompt −

$ jjs new.js
Hello World!
Published on 31-Jan-2018 08:08:49