This has fallen a little out of date, but the basics are here:
Other than that you should look through the docs for the JSscripting helper library:
https://openhab.github.io/openhab-js/index.html