HTML and CSS Reference
In-Depth Information
Figure 5.7 Concatenation of a string and a number.
Table 5.5 The Concatenation Operator
Operator
Example
Meaning
+
"hot" + "dog"
Concatenates (joins) two strings; creates "hotdog" .
"22" + 8
Converts number 8 to string "8" , then concatenates
resulting in "228" . In statements involving other
operators, JavaScript does not convert numeric
values to strings.
+=
x ="cow"; x += "boy";
Concatenates two strings and assigns the result to x ;
x becomes "cowboy" .
5.2.5 Comparison Operators
When operands are compared, relational and equality operators are used. The operands
can be numbers or strings. The result of the comparison is either true or false —a Boolean
value. Strings are compared letter by letter (lexographically) using Unicode 1 values to rep-
resent the numeric value of each letter; thus, “A” is less than “B”, and when comparing
“Daniel” with “Dan” , “Daniel” is greater than “Dan” . When comparing strings, JavaScript
pads “Dan” with three spaces to make it the same length as “ Daniel ”. Refer to Table 5.6.
Table 5.6 Comparison Operators
Operator/Operands
Function
x == y
x is equal to y
x != y
x is not equal to y
x > y
x is greater than y
Continues
1. Unicode is not supported in versions of JavaScript prior to 1.3. Unicode is compatible with ASCII charac-
ters. The first 128 Unicode characters correspond to the ASCII character set and have the same byte value.
 
 
Search WWH ::




Custom Search