Inside the resource tag you can write the JS code, for example alert with “Say Hello” (The function will get an event parameter):

The next thing to do, is call the function from the required object. So. Let’s say we want to call the function from a command button.
For that, we will drag an operation component call “Client Listener” over the CommandButton. On the Method name write down the name of the JS function, and choose “action” for the Type:

That’s it. Run the application and test the JS execution:

You have many other options when running JS from ADF. For example – you want to populate a field with value from other field or fields.
In the next example, I’m concatenating the Employee’s first & last name and populates it to another InputText field.
For that, I’ve added a new InputText field and dragged a ClientListener component on it. This time I choose “click” for the type: