SOURCE

console 命令行工具 X clear

                    
>
console
var number1 = 22;
var number2 = 33;
var mySrtring = 'ww';

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

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

var stringSum=mySrtring+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")+"<br/>");

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("<br/>-------------------<br/>");

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

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

//把数字转化成字符串
document.write("<br/>-------------------<br/>");
var number=1;
var stringNumber=1+"";
var stringNumber2=number.toString();
document.write(stringNumber+"<br/>");
document.write(stringNumber2+"<br/>");

//转义字符
document.write("<br/>-------------------<br/>");
document.write("绿叶,<br/>初恋般的感觉~");
//alert("绿叶,\n初恋般的感觉");
document.write("<br/>-------------------<br/>");
document.write("绿叶,给你\'初恋\'般的感觉~"+"<br/>");
document.write("绿叶,给你\"初恋\"般的感觉~"+"<br/>");

<!DOCTYPE html> 
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <!--script>
        var number = 10;
        var a;
        var myString='Heather';
        var noSpace=null;
        var isReal=true;
        document.write(number+'<br/>');
        document.write(a+'<br/>');
        document.write(myString+'<br/>');
        document.write(noSpace+'<br/>');
        document.write(isReal+'<br/>');
    </script-->
    <!--script>
        var $a=3;
        document.write($a+"<br/>");
    </script-->
</head>
<body>
</body>
</html>