| Refresh | Home EGTry.com

string operators


commentsJavascript sourceExecution result in your current browser
+ string concatenation
var s1="hello";
var s2="world";
var msg=s1+" "+s2;
document.write(msg);

+ convert to string first
msg="the hour now is "+14;
document.write(msg);

> or < alphabetical comparison
document.write(("A" < "a")+"<br/>");
document.write(("1" < "A")+"<br/>");

> or < convert to number first if one operand is number
document.write( ("10" > "9") +"<br/>");
document.write( ( "10" > 9 ) +"<br/>");