How to run JavaScript using jsc on OS X?

Viewed 22985

I got this when I was trying to find some way to run my JavaScript programs through terminal. The run and load command mentioned can execute external JavaScript files. Help me how to do this. I am trying to run JavaScript programs which are store locally on my system.

EDIT: I am trying to solve Project Euler Q10 in JavaScript. So this is the program that I want to run in NodeJs or JSC. I need help in running the JavaScript files in Node and JSC. Any example will be really helpful.

Thank You all.

4 Answers

NOTE for MacOS Catalina (10.15.x) users

jsc now lives on a new path:

/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Helpers/jsc

Make that adjustment to @hurrymaplelad's instructions and you'll be good to go.

For future reference: I made a GitHub gist with updated info on using JSC, is available here.

Related