Last I checked the javascript documentation for OSA was pretty incomplete. I needed to script something on a mac the other year and had to use AppleScript because I couldn't figure out how to do something extremely basic (like get a hash out of some app or something, I don't remember.)
In theory there should be a mapping from AppleScript APIs and objects to JavaScript, but it may not always be obvious.
I wish Apple had better developer documentation in general.
It seems to have taken a downturn recently even as they have accelerated feature velocity with things like SwiftUI.
Apple's Open Scripting Architecture is something like 30 years old at this point. Macs have been scriptable using JavaScript for more than 20 years (JavaScript OSA, 2001), and JXA has been included in macOS since 2013.
AppleScript may have been something of a failure, but HyperTalk (which it was based on) was a huge success.
Personally I like AppleScript, even if I mainly use Python (and occasionally JavaScript) for scripting macOS and iOS. Now I want to try Late Night Software's Script Debugger 8, which looks like a nice IDE for AppleScript.