Posted Monday, December 6, 2004
Start at the Beginning
Comment, Comment, Comment
Commenting code allows you, or someone else looking at it, to understand what's occuring in the code. Commenting can be done in both single and multi-line variations:
// single line comments
Numeric: var x = 0;
String: var y = "hello";
Variables: var z = x + y;
Object: var myImage = new Image();
Ex: var x = hello ** wrong
Variables that store numbers and strings can be combined in a new variable. However, if anything is combined with a string, it is automatically be treated as a string.
Ex: var y = "1";
var z = "2";
var a = y + z;
The variable "a" in this instance is "12" not 3, since the two strings were combined together as text, not added like numbers. This would be true even if y = 1.
Making a Statement
Examples of alerts
alert("this is a string");
creates an alert that will contain the text"this is a string"
creates an alert that will contain the value defined in variable x (make sure that variable x is defined before calling it)
alert("the number is " + x);
-creates an alert that will combine text and the value in x.
It Can Do Math Too?
greater than >
less than <
greater than or equal >=
less than or equal
This document is provided for informational purposes only, and i-Netovation.com makes no warranties, either expressed or implied, in this document. Information in this document is subject to change without notice. The entire risk of the use or the results of the use of this document remains with the user. The example companies, organizations, products, people, and events depicted herein are fictitious. No association with any real company, organization, product, person, or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, wit hout the express written permission of i-Netovation.com.
If you believe that any of these documents, related materials or any other i-Netovation.com content materials are being reproduced or transmitted without permission, please contact: firstname.lastname@example.org.
The names of actual companies and products mentioned herein may be the trademarks of their respective owners.
(C) Copyright 2002. Lisa Spurlin
About the Author