So that, you can use it like this:
Syntax: {!$Component.afield}
The above syntax uses properties of the field in the javascript. Take an example:
You are going to store the field’s values in javascript, then the code will display like this:
<script>
Var a = 'document.getElementById('{!$component.afield}').value';
</script>