<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript">
// arguments进行函数传递
function test(){
var sum=0;
for(var i= 0;i<arguments.length;i++){
sum+=arguments[i];
}
console.log(sum);
}
test(200,300);
</script>
</body>
</html>
数据类型及转换
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<!--
原始数据类型
js中的数据类型:
数值型(Number)
字符串(String)
布尔型(boolean)
函数型(function)
对象(Object):例如window,document,json,数组
-->
<!-- typeof
查看类型
-->
</head>
<body>
<script type="text/javascript">
var a= '10';
// Number(a)转成整数 纯数值字符串
// 加法成连接
console.log(Number(a)+10);
// 内部进行转换 NaN 转换错误的提示
console.log(a-10);
console.log(a/10);
console.log(a*10);
//parseXX()取数值
var num='100px';
console.log(parseInt(num));
// isNaN()内部是有number转换的
console.log(isNaN())
</script>
</body>
</html>
网友评论