It's a sensible development
OS X is already a fully scriptable OS and JavaScriptCore has elevated Apple's JavaScript implementation to a system-level framework. Joining the dots probably took all of five minutes.
Apple has quietly started toying with the idea of using JavaScript as a task automator in the Yosemite version of OS X. In this pre-release API document, Cupertino outlines JavaScript for Automation. It's an OSA component that the document says “can be used from Script Editor, the global Script Menu, in the Run JavaScript …
There's already a scripting language, imaginatively titled AppleScript, which first appeared at the start of the '90s. Then there's the Automator, from the mid-'00s and which this article mentions, which provides a graphical way of wiring applications together. I would imagine the latter is more commonly used than the former nowadays but it's just a code generator underneath.
You don't need Xcode to write JavaScript.
Apple used to have an entire JavaScript toolchain for making OS X widgets. That was back in 10.5 or so. Last time I tried it, it had stopped working, but it wouldn't take much to revive it.
Currently you do need Xcode to write/run Swift.
I mean if someone were interested in learning Swift they'd need to use XCode but if Swift were in included in Automator as well it'd be much more accessible. They should have used Swift as Automator's second scripting language, not JavaScript. JavaScript's already in the browser anyway.
JavaScript is widely understood by anyone who's ever cobbled together a website, so that's one advantage over Swift.
Also, unlike Swift, JavaScript isn't controlled by Apple, and thus won't get dumped just as you've put enough hours into it to become competent in it (Apple have a very bad track record in this). The corollary is that the long hours spent becoming more competent with JavaScript will benefit many other projects you might have to work on; not so with Swift.
Another advantage, considering the fields where most of Apple's OSX users actually work, is that Photoshop's extensive scripting features also use JS.