JavaScript can do whatever the environment lets it do. Obviously browser based JavaScript is extremely limited but JavaScript running outside of a browser (e.g. on a server, or in a desktop application) can and does do all of those things you say it can't do.
It's been a long time since I've ever done any AppleScript so I can't really compare, but it does seem like the JXA environment can do any of those things, since it has an Objective-C bridge[0].
[0] https://developer.apple.com/library/content/releasenotes/Int...