3 ms·
Interestingly I learnt recently that macOS includes a ``jsc'' command, which provides a built-in JavaScript REPL and interpreter [0]. It is part of the JavaScri
by nishs 5y ago
Interestingly I learnt recently that macOS includes a ``jsc'' command, which provides a built-in JavaScript REPL and interpreter [0]. It is part of the JavaScriptCore framework. I can find it at:
/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers/jsc
But a Stack Overflow comment says it moves around between releases, so you may want to find it first using:
$ find /System/Library/Frameworks/JavaScriptCore.framework -iname jsc
It doesn't support web-specific APIs such as window. But it includes extras such as a print function and a readline function.
$ cat greet.js
print("What is your name?")
const name = readline()
print(`Hello, ${name}!`)
$ jsc greet.js
What is your name?
ns
Hello, ns!
$
Have fun :)
[0]: https://furbo.org/2021/08/25/jsc-my-new-best-friend/ https://furbo.org/2021/08/25/jsc-my-new-best-friend/