Simplest function
<html> <head> <script language="JavaScript"> <!-- function TestFunction() { var localVar = "Hello"; } alert(localVar); //--> </script> </head> </html>