JXA quick guide?

So I have a lot of experience writing bare javascript code.
And I begrudgingly have a lot of experience writing applescript code.

I’ve been playing around writing AS in JS in the editor when I’m doing little tests and every time I say to myself OMFG YES THIS IS HOW A SCRIPTING LANGUAGE IS SUPPOSED TO WORK. Like “string.split(”|“)” instead of “set applescript’s text item delimiters to “|””

So anyway, I’m well positioned to make a quick transition, I just need a little help getting started. Like literally, how do you do the run handler? And the open handler? Basically everything that is applescript specific.

For what it’s worth, I don’t even like Javascript. But compared to Applescript native syntax, i LOVE javascript :smiley: And writing AS in JS, I’m confident will let me to a lot more, a lot easier.

There are definitely parts of JS that are more powerful than AS. However, JS doesn’t have named parameters, which is a barbaric approach.

The JavaScript part seems to work OK, but the Apple Event part (the “Automation” bit) is half-baked at best. I had very little luck with it for anything but simple stuff; good thing I don’t like the language either (I much prefer Ruby). The Objective-C/Cocoa bridge seems to be better, but unfortunately JXA wound up being just another nail in the coffin for the Automation team.