1.javascript变量的分类:

A.基本(值)类型
string
Number
boolean
undefined
null
B.对象(引用)类型
object
function //一种特别的对象(可以执行)
Array //一种特别的对象(数值下标,内部数值都是有序的)

2.判断数据类型

A.typeof
B.instanceof
C.===

判断一个变量是否是undefined的具体方法

var a
console.log(a,typeof a,typeof a==='undefined',a===undefined )
//输出 undefined,undefined,true,true
var b=4
console.log(typeof b==='number')  //true
console.log(undefined==='undefined')   //false
var c=null
console.log(typeof c)   //object  

注意要点:undefined==='undefined' 是错误的,不能这样子表示,加了一个引号其差别极大,左边是数值,右边是对象

var object1={
    a:[1,'abc',console.log],
    b:function(){
        console.log('b');
    }
}
console.log(object1 instanceof Object,object1 instanceof Array);  //true  false
console.log(object1.a instanceof Array,object1.b instanceof Object);  //true   true
console.log(object1.b instanceof Function);   //true
console.log(typeof object1.b==='function')   //true
console.log(typeof object1.b[2])    //function

3.类型和实例对象

类型其实通俗来讲是一个模板,术语上讲叫做构造函数

function Person(name,age){
    this.name=name
    this.age=age
}

实例对象:
通俗来讲就是在类型当中定义一个真正的对象

var p=new Person()

4.undefined和null的区别

undefined表示定义了为赋值
null表示定义了,赋值了,但是是null空值

5.释放变量空间

最后将b指向的对象变为垃圾对象,释放空间

var a=null
a=['laozhichi','love','liulijuan']
a=null 

6.什么时候使用null

A.初始化变量为null,表示其将赋值为一个对象
B.结束前,想将对象变为垃圾对象

7.在内存当中:不同数据的存储状况

A.在存储基本类型数据的时候,存储的就是基本数据类型的数值
B.在存储(对象)引用类型数据的时候,实际上是在存储其地址值


风继续吹
1 声望0 粉丝