Javascript: Syntax




To contact us



[
HOME] Consulting Design Maintenance Project Testing Training Turnkey Java C++ SQL HTML JavaScript ]

© 2002 - 2014 All Rights Reserved Total Application Works


  • Tell a friend about this site (copy and paste the following HTML page into a file (e.g., using Notepad).)
  • <html>
    <head>
    <title>Example of a link </title>
    </head>
    <body>
    <a href="http://sumtotalz.com/TotalAppsWorks/Javascript/JS_Syntax.html">
    JavaScript Syntax </a>
    </table>
    </body>
    </html>

JavaScript Syntax

<

Introduction to JavaScript Syntax

The purpose of this tutorial is to introduce you to the basics of JavaScript Syntax. You can find a brief introduction to Javascript at this reference.

What is syntax?

Syntax is the set of rules that govern the structure or how the parts of a sentence go together.

What is JavaScript Syntax?

JavaScript syntax is the set of rules that govern the structure or how the parts of a JavaScript program are structured. Stated another way, JavaScript syntax refers to a set of rules that determine how a programmer will use the language to write a program and how a browser will interpret the program.

If you are familiar with the Java syntax, you will see similarities between the JavaScript syntax and the Java syntax. Java is a full-blown programming language and JavaScript could be viewed as a sub-set of the Java language. With the above concepts in mind, this is where the similarities end - Java and JavaScript are two totally different programming languages.

As we probe the JavaScript syntax, hopefully, we will become familiar with terms such as variables, functions, statements, operators, data types, objects etc.

An example of a basic JavaScript file is displayed in the following figure.

Source Code Displayed in your Browser
<div style="background-color:lightskyblue">
<pre>
<code>
<script type="text/javascript">
<!--
document.write("JavaScript is similar to Java
but it is not Java

<b>Ronald S. Holland
at
Total Application Works</b>");
-->
</script>
</pre>
</code>
</div>


Figure 1:


A brief description of the code is:
  • <div> - defines a division or a section in an HTML document.
  • <script type="text/javascript"> - this tag informs the browser to expect a JavaScript script.
  • <code> - this tag specifies computer code text
  • <pre> - "preformats" the text is rendered exactly as you type them.
  • <!-- - this is the start of a comment. Comments are not displayed in the browser
  • document.write("JavaScript is similar to Java but it is not Java");
  • -->- this is the end of a comment.
  • </script>>- this is the end of a script.
  • </pre>>- this is the end of preformatted text.
  • </code>>- this is the end of a code text.
  • </div>- this is the end of a section defined by the div tag.

Where do your scripts go?

You can place your scripts in any of the following locations:

  • Between the HTML document's <head> and </head> tags.
  • Within the HTML document's body (i.e. between the <body and </body> tags).
  • In an external file (and link to it from your HTML document).









HOME] Consulting Design Maintenance Project Testing Training Turnkey Java C++ SQL HTML JavaScript ]


To contact us

© 2002 - 2014 All Rights Reserved Total Application Works