help newbie

I’m just learning how to program, and I do not understand how to glish components to a file outside the html file.
Can you give me a simple example?
Thank you

Could you please, clarify your request.

the javascript file I wanted to put it in an xx.js file and import it into the head of the html type:

<script type="text/javascript" src="miojavascript.js"></script>

in order to separate the html code from the javascript code.