• JS深入理解


    数据类型

    • 分类

      • 基本(值)类型
        • string 任意字符串
        • number 任意数字
        • boolean true / false
        • undefined undefined
        • null null
      • 对象(引用)类型
        • object 任意对象
        • function 一种特别的对象(可执行)
        • array 一种特别的对象(数值下标,内部数据是有序的)
    • 判断

      • typeof
        • typeof返回数据类型的字符串表达
        • 可以判断 undefined数值字符串布尔值
      • instanceof
        • 判断对象具体的类型
      • ===
    // 判断undefined
    var a;
    console.log(typeof a === 'undefined'); // true
    console.log(a === undefined);   // true
    // 判断数字,字符串,布尔值
    a = 4;
    console.log(typeof a === 'number');   // true
    a = 'abcd';
    console.log(typeof a === 'string');   // true
    a = true;
    console.log(typeof a === 'boolean');   // true
    console.log(a === true || false);   // true
    a = null;
    console.log(typeof a === 'object');   // true 不能判断
    console.log(a === null);   // true
    
    var b1 = {
        b2: [1, 'abc', console.log],
        b3: function(){
            console.log('b3');
            return function(){
                return 'dcba';
            }
        }
    }
    console.log(b1 instanceof Object);  // true
    console.log(b1.b2 instanceof Array);  // true
    console.log(b1.b3 instanceof Function);  // true
    console.log(typeof b1.b3 === 'function');  // true
    console.log(typeof b1.b2[2] === 'function');  // true
    b1.b2[2](4);
    console.log(b1.b3()());
    

    数据,变量与内存

    对象

    函数

  • 相关阅读:
    观察者模式
    策略模式
    设计模式之Template Method
    面向对象设计原则
    设计模式简介
    封装Server类和Client类
    为客户端添加输入线程
    客户端升级为select网路模型
    将服务端select设置为非阻塞,处理更多业务
    Laradock 使用中遇到的问题汇总
  • 原文地址:https://www.cnblogs.com/SharkJiao/p/13828915.html
Copyright © 2020-2023  润新知