Ans:There are several way for adding JavaScript on a web page, but there are two ways which are commonly used by developers
If your script code is very short and only for single page, then following ways are the best:
a) You can place <script type="text/javascript">
tag inside the <head>
element.
<head>
<title>Page Title</title>
<script language="JavaScript" type="text/javascript">
var name = "Vikas Ahlawta"
alert(name);
</script>
</head>
b) If your script code is very large, then you can make a JavaScript file and add its path in the following way:
<head>
<title>Page Title</title>
<script type="text/javascript" src="myjavascript.js"></script>
</head>