I just wanted to kind of summarize some of what’s been already said here just in case someone in a hurry misses something.
JavaScript and ECMAScript are the same thing.
OH supports ECMAScript 5.1 through the Nasorn JS Scripting add-on. Do not use this, it’s there to support those who got started with Nashorn JS a long time ago and can’t or won’t move to the newer add-on. Nashorn JS does not come with a helper library (though there is an incomplete third party one on GitHub) meaning that all your interactions with OH will use the raw Java JSR223 APIs. This means writing rules will be tedious, long, and have to deal with Java stuff a whole lot.
OH supports ECMAScript 2022+ through the GraalVM JS Scripting add-on. This is the most recent version of the language (I think 5.1 was release something like 8 years ago but could be even older, I’ve not looked it up). The GraalVM JS Scripting add-on comes with a helper library called “openhab-js”. This library abstracts the raw Java JSR223 API to openHAB in rules to provide a nice and clean and pure JS API for interacting with openHAB.
jRuby similarly comes with a helper library to provide a nice Ruby interface with openHAB.
I want to reemphasize @jimtng’s answer here. MainUI does use JavaScript, but except for some of the very basics, there is little overlap between the sorts of JS you’d be doing in MainUI and the JS you’d be doing in a rule. For one thing, there’s no openhab-js. For another, it’s a completely different environment (rules run on the server, MainUI runs on the browser). So while there is a tiny bit of overlap, there is really no compelling reason to chose JS over jRuby just because you will encounter a few lines of JS in MainUI.
And I want to emphasize that last bit even more too. Mostly what you’ll be doing in MainUI is configuring widgets. You are not writing JS code except a limited set of well documented expressions that, for example, lets you set the color and icon of a widget based on the states of Items. You will only be using one-liners here, not writing blocks of JS code. openhab-js is not available there.
One nice thing that might help with learning JS is that Blockly “compiles” to JavaScript. So you could build up some code using Blockly and look at the resultant JS code it generated to learn how to do things in JS. Often it can be easier to plug the blocks together or see the options available on a block and look at the code that it is to review the reference docs.
Beyond that, both JS Scripting and jRuby each have a good helper library that simplifies the interaction with OH and presents a language pure interface (e.g. when you access the members of a Group Item, you get a language native list/array that can be treated like any other list/array you’d encounter in the language; without the helper library you’d end up with a Java List Object and would have to iterate, search, etc. using Java techniques and methods, not JavaScript or jRuby standard methods). And you need do nothing special to get the library; they come with the add-ons.