Well, that's quite nifty. I never knew OS X had it's own javascript engine / component.
rterrell$ /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc
>>> for (var i=0; i<10; i++) { print("Hello World!", i); }
Hello World! 0
Hello World! 1
Hello World! 2
Hello World! 3
Hello World! 4
Hello World! 5
Hello World! 6
Hello World! 7
Hello World! 8
Hello World! 9
undefined
>>>
Edit to add: the submission reminds me of the old "Commando" for MPW. Very cool.* [JXA Cookbook](https://github.com/JXA-Cookbook/JXA-Cookbook)
* [JavaScript OS X App Examples](https://github.com/tylergaw/js-osx-app-examples)
For my application (URL in bio), I wrote a shell script that (mostly) automatically generates the screenshots for the Mac App Store. It uses osascript(1) with some JS to set the system colors/wallpaper/language to a particular style, position the app window where I want it, take a screenshot, block out my menubar extras, crop it to the requested size, etc.
OSA scripting is actually pretty powerful, but sadly the documentation is awful. Try:
osascript -l JavaScript -e 'Application("System Events").appearancePreferences.appearance = "graphite"'
(or "blue")[1]: https://en.wikipedia.org/wiki/AppleScript#JavaScript_for_Aut...