JavaScript基本数据类型和运算

<span style="font-size:18px;"><!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>


<script type="text/javascript">
function test1(){
window.alert("你点击了button");
}
function test2(){
//定义两个变量并且赋值
var num1=2;
var num2=3;
var res=num1+num2;
window.alert("num1+num2="+res);
}
function test3(){
var name="hello";
window.alert("name的类型是:"+typeof name);
}
function test4(){
var a="hello";
var A="world";
window.alert(a+"--"+A);
}
function test5(){
var n1=0x8a; 
var n2=0010123;
var n3=1234;
alert(n2);


}
function test6(){
var s="abc";
//parseInt() 函数是js的全局函数,可以直接使用
//在哪里查询
alert(parseInt(s));
var r=7/0;
alert(r);
}
function test7(){
window.alert("false, 0, “”, null  , undefined、NaN这些表示假");
var a=10;
if(a){alert("真")}
else{alert("假")}
}
function test8(){
window.alert("hello,china");
}
function test9(){
var num1=window.prompt("请输入第一个数:");
var num2=window.prompt("请输入第二个数:");
var res=parseFloat(num1)+parseFloat(num2);
window.alert("结果是:"+res);
}
function a(){
window.alert("+ 、-、* 、 / 、%");
}
function b(){
var jia=2+3;
var jian=3-2;
var cheng=2*3;
var chu=6/3;
window.alert(jia+"--"+jian+"--"+cheng+"--"+chu);
}
</script>
<body>
js入门程序<br/>
<input type="button" value="hello,world" οnclick="test1()">
<hr width="600px" align="left">
js变量和运算<br/>
<input type="button" value="js变量和运算" οnclick="test2()">
<hr width="600px" align="left">
js的变量类型是由js引擎决定,如果要查看某个变量的类型,则可以使用typeof运算符<br/>
<input type="button" value="js变量类型" οnclick="test3()">
<hr width="600px" align="left">
变量使用注意事项:<br/>
1.变量区分大小写<br/>
<input type="button" value="注意1" οnclick="test4()">
<hr width="600px" align="left">
js 的数据类型有 <br/>
基本数据类型[1. 整数 2. 实数 3. bool  4. 字串]<br/>
复合数据类型[1. 数组  2.对象]<br/>
特殊数据类型[1. null 2. undefined]<br/>
<input type="button" value="整数" οnclick="test5()">
<input type="button" value="实数" οnclick="test6()">
<input type="button" value="布尔" οnclick="test7()">
<input type="button" value="字符" οnclick="test8()">
<hr width="600px" align="left">
js 的数据类型转换 <br/>
<input type="button" value="js计算器" οnclick="test9()">
<hr width="600px" align="left">
js 的运算符 <br/>
<input type="button" value="js运算符" οnclick="a()">
<input type="button" value="运算案例" οnclick="b()">
<hr width="600px" align="left">
js 位运算,逻辑运算 <br/>
<a href="http://blog.csdn.net/dzy21/article/details/46986193">参考文章</a>
<hr width="600px" align="left">
</body>
</html></span>
<span style="font-size:18px;">运行结果:</span>
<span style="font-size:18px;"><img src="https://img-blog.csdn.net/20151118222818918" alt="" />
</span>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值