Start at Beginning
Comment, Comment, Comment
Commenting code allows you, or someone else looking at it, to understand what's occuring in code. Commenting can be done in both single and multi-line variations:
// single line comments
/* multi-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 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 text"this is a string"