Intro 3

[Total: 0    Average: 0/5]

Javascript Tutorial Intro – Page 3

What is a JavaScript?




JavaScript is a portion of code that runs before
the HTML is loaded, before the document is viewed,
during the document viewing, and as it is leaving.


Parts of JavaScript create HTML and is static after
that point.

Example:

<script>

document.write(“<H1>HI</H1>”);

</script>



This statement creates HTML code that has the text “HI” inside a
header of type 1.


After this JavaScript completes it’s task of writing
this text it is done and will do no more.



Things to notice:

1) The <script> and the </script> tags surround
the JavaScript code. These always surround JavaScript
Code. There are several different styles to mark the
edges of JavaScript code.

<script type=text/javascript>

<script “JavaScript”>

<script “JavaScript 1.2”>


and

2) There is a “;” at the end of every JavaScript line.
You may see places where the programmer left off the “;”.
This can be dangerous, because as the code is interpreted/
compiled, every line gets a “;” inserted if it does not have
one. So when you don’t want a “;” at the end of the line,
boom you get one any ways.

Example:

return

5


This returns “” instead of 5!

Times Viewed: 31

Leave a Reply

Your email address will not be published. Required fields are marked *