SOURCE

console 命令行工具 X clear

                    
>
console
var number1=22;
var number2=33;
var myString="Heather";

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

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

var stringSum=myString+number2;
document.write(sum+"<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);                

 var a = 2018 + "";
 document.write(a);

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

function fn(){
    document.write(a);
    var a=10;
}
fn();
document.write('<br/>-----------------<br/>');
<!DOCTYPE html> 
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script>
        var a= 3;
        document.write(a);
    </script>
</head>
<body>
</body>
</html>