1、CSS JS 规范+数据类型
window.onload = function(){
// var str = 'abc';
// var num = 123;
// var bool = true;
// var und = undefined;
// var n = null;
// var arr=['x','y','z'];
// var obj = {};
// var fun = function() {};
// console.log(typeof str); //string
// console.log(typeof num); //number
// console.log(typeof bool); //boolean
// console.log(typeof und); //undefined
// console.log(typeof n); //object
// console.log(typeof arr); //object
// console.log(typeof obj); //object
// console.log(typeof fun); //function
var str = 'xyz'
var num = 456
var bool = false
var und = undefined
var n = null
var arr = ['x','y','z']
var obj = {}
var fun = function(){}
console.log(typeof str)
console.log(typeof num)
console.log(typeof bool)
console.log(typeof und)
console.log(typeof n)
console.log(typeof arr)
console.log(typeof obj)
console.log(typeof fun)
var a = 10;
var b = a;
b = 20;
console.log(a); // 10
// var user = {
// name:'fangfang',
// id:1,
// age:18,
// img:''
// };
// var abc = user;
// abc.name = 'abc';
var user ={
name:'small yu',
id:8,
age:18,
img:''
}
var abc = user;
abc.name = 'xyz'
var obj1 = {};
var obj2 = obj1;
obj2.name = "obj2";
console.log(obj1.name); // obj2
//定义过程中的几种方式:
//数组
//1)构造函数
var arr = new Array();
arr[0] = 1;
arr[1] = 2;
arr.push(arr[2]);
//简法的定义方式
var arr2 = new Array('a','b','c');
//2)字面量表示法
var arr3 = ['x','y',true,1,2];
//对象object
//1)构造函数
var obj = new Object();
obj.name = "fangfang";
obj["age"] = 18;
//2)字面量表示法
//A-简单字面量
var obj2 = {};
obj2.name = "abc";
obj2.id = 1;
obj2.action = function(){}
//B-嵌套字面量
var obj3 = {
name:"xyz",
id:2,
age:18,
action:function(){
}
}
console.log(obj3.name,obj3.id,obj3.age)
//function 函数的定义方式
//函数声明
action();
function action(x,y){
return x+y
}
//函数表达式
var action2 = function(x,y){
return x+y
}
//二种方式的区别:由于预解析,函数声明可以先调用再声明,函数表达式不行
}
标签:arr,console,log,数据类型,JS,typeof,var,CSS,name From: https://www.cnblogs.com/jycom/p/16656406.html