1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:08:10 +00:00
serenity/Base/usr/share/man/man1/js.md
Linus Groh 8b76a1e548 js: Remove test mode
Now that we have a standalone test-js program, the "-t" test mode of the
js REPL is unused and can simply be removed. Required functionality has
been duplicated in test-js (isStrictMode function, loading of testing
utilities).

Also remove outdated information about tests from the js(1) man page.
2020-07-07 00:21:30 +02:00

1.1 KiB

Name

js - evaluate JavaScript

Synopsis

$ js [options...] [script.js]

Description

js evaluates JavaScript programs using the LibJS engine. If you pass it a path to a script file, it will execute that script. Otherwise, it enters the Read-Eval-Print-Loop (REPL) mode, where it interactively reads pieces (usually, single lines) of code from standard input, evaluates them in one shared interpreter context, and prints back their results. This mode is useful for quickly experimenting with LibJS.

Run help() in REPL mode to see its available built-in functions.

Options

  • -A, --dump-ast: Dump the Abstract Syntax Tree after parsing the program.
  • -l, --print-last-result: Print the result of the last statement executed.
  • -g, --gc-on-every-allocation: Run garbage collection on every allocation.
  • -s, --no-syntax-highlight: Disable live syntax highlighting in the REPL

Examples

Here's how you execute a script:

$ js ~/js/type-play.js

And here's an example of an interactive REPL session:

$ js
> function log_sum(a, b) {
>     console.log(a + b)
> }
undefined
> log_sum(35, 42)
77
undefined