SOURCE

var number1=22;
var number2=33;
var myString = "Heater";
var floatNum=3.14;
var notDefined;
var noSpace = null;

document.write(number1 + "<br/>");
document.write(myString + "<br/>");
document.write(floatNum + "<br/>");
document.write(notDefined + "<br/>");
document.write(noSpace + "<br/>");

var sum=number1+number2;
document.write(sum+"<br/>");

var sumString=number1+myString;
document.write(sumString+"<br/>");

var stringsum=myString+number2;
document.write(stringsum+"<br/>");

var stringNum=number1+"";

var stringNumSum=stringNum+number2;
document.write(stringNumSum+"<br/>");

document.write('<br/>-------------------------------<br/>');

var left = 1;
var right = 2;

left +=right;
document.write(left + "<br/>");

left -=right;
document.write(left + "<br/>");

left *=right;
document.write(left + "<br/>");

left /=right;
document.write(left + "<br/>");

document.write('<br/>-------------------------------<br/>');

left = (1+2) + 3;
right = (3+4) + 1;

document.write((left > right)+"<br/>");
document.write((left < right)+"<br/>");
document.write((left >= right)+"<br/>");
document.write((left <= right)+"<br/>");
document.write((left == right)+"<br/>");
document.write((left != right)+"<br/>");

document.write('<br/>-------------------------------<br/>');





var logicOperation = false;

logicOperation = (left > right)&&(left < right);
document.write( logicOperation + "<br/>");

logicOperation = true&&(left < right);
document.write( logicOperation + "<br/>");

logicOperation = (left > right)||(left < right);
document.write( logicOperation + "<br/>");

logicOperation = (left > right)||false;
document.write( logicOperation + "<br/>");

logicOperation = !(left > right);
document.write( logicOperation + "<br/>");
logicOperation = !(left < right);
document.write( logicOperation + "<br/>");

document.write('<br/>-------------------------------<br/>');

document.write("Number('123'):" + Number("123") + "<br/>");
document.write("Number('3.1415'):" + Number("3.1415") + "<br/>");
document.write("Number('hao123'):" + Number("hao123") + "<br/>");
document.write("Number('100px'):" + Number("100px"));

document.write('<br/>-------------------------------<br/>');
document.write("parseInt('123'):" + parseInt("123") + "<br/>");
document.write("parseInt('3.1415'):" + parseInt("3.1415") + "<br/>");
document.write("parseInt('hao123'):" + parseInt("hao123") + "<br/>");
document.write("parseInt('100px'):" + parseInt("100px"));
document.write("parseInt('+123'):" + parseInt("+123") + "<br/>");
document.write("parseInt('-123'):" + parseInt("-123"));

document.write('<br/>-------------------------------<br/>');
document.write("parseFloat('123'):" + parseFloat("123") + "<br/>");
document.write("parseFloat('3.1415'):" + parseFloat("3.1415") + "<br/>");
document.write("parseFloat('hao123'):" + parseFloat("hao123") + "<br/>");
document.write("parseFloat('100px'):" + parseFloat("100px"));

document.write('<br/>-------------------------------<br/>');
var result = (2 < 1)? "小生" : "小名";
document.write(result);

document.write('<br/>-------------------------------<br/>');
var number = 1;

//把数字转换为字符串
var stringNumber2 = 1 + "";

var stringNumber = number.toString();
document.write(stringNumber + "<br/>");
document.write(stringNumber2 + "<br/>");

/*使用转义字符*/
//alert("Hi \ 'Heather\'!\n Hello");

var a = 123 + "" ;
var b = a + 1234;
var c = a.toString() + 1343;
document.write(c);
document.write(b);
document.write('<br/>-------------------------------<br/>');

var q=1,w=2,e=3;
if(q<2)
    document.write("true");

if(q<1)
    document.write("true");
else
    document.write("false");
console 命令行工具 X clear

                    
>
console