All that code will be executed at the client side i.e. browser that is running your web page.
This is really a useful thing, otherwise, you have to send a request to the server to perform operations that can be done quickly and without increasing load at the server.
These are a few online examples from different tutorials:
Chapters in this Tutorial
- JS Tutorial
- The if statement
- The Switch statement
- The while loop
- Custom Functions