Developers Journal - JavaScript and AJAX

The objective of this assignment is to learn more about complex JavaScript functionality. While I already know a great deal about JavaScript, I wish to know even more about it. This is also leading into another research project focused on jQuery and HTML 5 Animation.

Write to the Page

Code:


<script type="text/javascript">
     <!--
     document.write("<h1>Put This On The Page</h1>");
     //-->
</script>

Example:

Variable Names

Code:


<script type="text/javascript">
     // Variables can start with a letter, underscore or dollar sign
     // Numbers can exist as a variable name but not as the first character
     var letters = 'abcABC';
     var numbers123 = 1 + 2;
     var _undersore = '_';
     var $dollarSign = '$';
     
     document.write(letters);
     document.write('<br/>');
     document.write(numbers123);
     document.write('<br/>');
     document.write(_undersore);
     document.write('<br/>');
     document.write($dollarSign);
     document.write('<hr/>');
     
</script>

Example:

Declare and Redeclare Variable

Code:


<script type="text/javascript">
     // Declare a variable named X and set it to 5
     var x = 5;
     document.write(x);
     document.write('<br/>');
     
     // Redeclare a variable with no preset, it should maintain it's previous value
     var x;
     document.write(x);
     document.write('<br/>');
     
     // Redeclare a variable with a new preset
     var x = 5*9;
     document.write(x);
     document.write('<br/>');
     
</script>

Example: