您的位置:首页 > Web前端 > JavaScript

<Js>数据类型

2016-05-20 17:09 543 查看
//Number:数字
var num = new Number(1.568);
document.write("num = "+num+"<br>");

var num1 = 20.1;
document.write("num1 = "+num1+"<br>");

//清空
num1 = null;
document.write("num1 = "+num1+"<br>");

//无value
var num2;
document.write("num2 = "+num2+"<br><br>");


//String:字符
var str = new String("ABC");
document.write("str = "+str+"<br>");

var str1 = 'asd';
document.write("str1 = "+str1+"<br><br>");


//Array:数组
var arr = new Array("a",'d',1);
document.write("arr = "+arr+"<br>");

var arr1 = ["a",'d',1];
document.write("arr1 = "+arr1+"<br>");

arr1[0] = "dd";
arr1[1] = '12';
document.write("arr1,arr1 = "+arr1[0]+","+arr1[1]+"<br><br>");


//Boolean:布尔
var bool = true;
document.write("bool = "+bool+"<br>");
bool = false;
document.write("bool = "+bool+"<br><br>");


//Object:类
var obj = {
df:"df",
sss:'12',
ff:[1,'3',true]
}
document.write(obj["df"]+"<br>");
document.write(obj.sss);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: