基础深入总结

数据类型

基本(值)类型

  • string:任意字符串
  • number:任意数字
  • boolean:true/false
  • undefined:undefined,定义了但未赋值
  • null:null,定义了,只是值为null

对象(引用)类型

  • Object 任意对象
  • Array 一种特别的对象(可执行)
  • Function 一种特别的对象(数值下标,数据有序)

判断

  • type of 返回的是字符串
    • 可以判断undefined、数值、字符串、布尔值、function
    • 不能判断null与object 、object与array
  • instanceof
    • 判断对象具体类型
  • ===
    • 可以判断 undefined,null
  1. undefinednull区别?

undefined代表定义了但是未赋值,null定义并赋值了,只是值为null

  1. 什么时候给变量赋值为null?

初始赋值,表明将要赋值为对象。

  1. let a = null
  2. a = [1,2]
  3. a = null // 切断引用,回收[1,2](被垃圾回收器回收)
  1. 什么是数据?什么是内存?什么是变量?