This guy ( Ayushv ) knows his JavaScript – you might want to check out his “medium” based blog posts on the subject.
https://ayushv.medium.com/
Functions are “high order” – are javascript objects – and can be passed as parameters “Fat Arrow Functions” easily allow
Selenium find element by name, id, xpath etc for java, python etc. supported languages. https://riptutorial.com/selenium-webdriver/example/13934/locating-page-elements-using-webdriver Additionally, if writing/accessing selenium API
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro codepen.io jsbin.com