How do you run JavaScript script through the Terminal?

前端 未结 16 1801
离开以前
离开以前 2020-12-02 04:00

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

16条回答
  •  悲哀的现实
    2020-12-02 04:08

    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

    .exit
    

    You can also run a JavaScript file like this:

    node file.js
    

    « Install it NOW »

提交回复
热议问题