Googling “how to learn javascript for beginners” here’s some top hits:
The basics for controlling an application is to get an application object, execute methods of the object to get the needed information or the desired effect. You can get information about each application objects valid methods from the File > Open Dictionary menu in the Script Editor.
It is really simple and mostly self-explanatory. Let’s go over it together.
https://cdn-images-1.medium.com/max/2400/1*-SxWfDsCXWKnH76rvypPOQ.png

Firstly, we create a couple of variables that we will use frequently: currentApp for prompting something in the current application, finder for creating and moving files around and systemEvents for accessing to files.
The OS has a set of standard scripting additions that provide the ability to speak text, display user interaction dialogs, and more. To use them, an application must explicitly set the includeStandardAdditions flag to true. The third line stands for that. We’re declaring that we want to use these additions.
After that, we prompt a folder chooser panel to get the folder to be processed. Then we create a new folder in the same directory to move the processed files into it."
And from our own @DanThomas
I’ll tell you right up front - getting up to speed is a daunting task, because the documentation, when there actually is some, is extremely sparse. That’s why I’m hoping you’re willing to document your experience, here in this topic.
While JXA initially looks cool and capable of producing results fast and perhaps easier then via AppleScripting, getting into JXA from the perspective of not really knowing anything about scripting and given the seemingly little being offered directly for the rank novice isn't as approachable as I’m finding for AppleScripts.
I don’t have the necessary distinctions to compare the two languages to meaningfully evaluate whether it’s worth taking the perhaps shorter but seemingly more difficult climb to get going with JXA rather than AppleScripts. It seems AppleScripts was designed with learning it baked into its very structure. That gets a LOT of points from where I’m standing.
Of course the argument that “So what? When you get to the top of that mountain you’ll find that it’s not all that great compared to what you see on the JXA mountain” can be leveled and again I can’t effectively argue.
Do I really want to learn AppleScripts? No . I just want to do some really simple stuff like file some stupid receipts and make some notes and organize some information. Are the tools ALREADY available to do that? YES. And..
I could just read physical books, write on paper, and throw receipts into a shoe box like most people and rummage around looking for stuff when I want or need it but computers appeared and damn it I'm going to get it to do what I want it to do the way I want it to do it and now if that means learning all this coding language thenI will! Do I "want to", no.