That‘s an excellent example, with many important basic maneuvers demonstrated! Many thanks. (Having this example somewhere very obvious would save a great deal of mucking around for anyone approaching JXA for the first time, especially people who are intimidated by the idea.
It would be nice if there were a category for example scripts — not scripts that do interesting or elaborate things, but scripts that are designed to demonstrate how to do various things in the various scripting languages. Yes I know that the JXA Cookbook cited in the next paragraph has some of this for JXA, but I don't know where to find such things for the other languages. I just do a lot of Googling, and collect good starting points. (See my Website Popups Using Automator, also known as Open Standalone Web Pages — Great for References.)
I've got my trivial alert script untangled. The problem is that there is no alert! (See User Interactions · dtinth/JXA-Cookbook Wiki for information on programming dialogues in JXA.) Here‘s what my successful script looks like now:
var app = Application.currentApplication();
app.includeStandardAdditions = true
app.displayAlert("atom.js");
I still don’t understand who is running the script (context).
I also don‘t understand how Atom knows to run this as JXA and not JavaScript or node.js. I did do the Edit | Select Grammar
menu command — do you think that’s enough for Atom’s script
package to know what to do?