JS高级

1、JS正则表达式

  1. 使用正则表达是的字符串的三个API正则表达式

    //(1)replace基础用法
    var str = "welcome to my home"
    str = str.replace(/m/g,'x')
    console.log(str)//welcoxe to xy hoxe
    //(2)replace进阶用法
    var str = "welcome to my home"
    str = str.replace(/\b(\w)|\s(\w)/g,(val)=>{
        console.log(val)
    })
    //(1)search的用法
    var str = "hello world"
    c = str.search('h')
    console.log(c)//0
    //(2)支持正则的用法
    c = str.search(/o/g)
    console.log(c)//4
    //(1)match的正则用法
    var str = "who am i,i don't konw"
    arr = str.match(/k[\w]+w/g)
    console.log(arr)//['konw']
    
    //(2)match的普通用法
    var str = "tom is a good boy"
    lon = str.match('tom')
    console.log(lon)//[ 'tom', index: 0, input: 'tom is a good boy' ]
    //若是匹配不到值返回null
    
    //(3)match的进阶用法
  2. 正则的进阶知识数组

    • 字符串的API
    • 普通用法闭包

      var str = "hello"
         arr = str.split('')
         console.log(arr)//['h','e','l','l','o']
    • 正则用法app

      var str = "hello world"
      arr = str.split(/\s/g)
      console.log(arr)

2、面向对象

  • 封装
  • 继承
  • 多态

3、原型链与做用域链

  1. 原型链
  2. 做用域链

4、ES5

  1. 严格模式:函数

    • 严格模式的实现this

      1. "use strict"
      2. 禁止给未声明的变量赋值
      3. 将禁默失败升级为错误
      4. 普通函数的调用中的this不在指向window,而是指向undefined
    • ES5的对象保护code

      1. 单个属性保护对象

        • 访问器属性
        • 数据属性
      2. 对象结构的保护继承

        • 防扩展
        • 密封
        • 解冻
      3. 属性的分类原型链

        • 命名属性
        • 数据属性
        • 访问器属性
        • 内部属性
        • class属性
      4. 替换this的三种方式

        • call
        • bind
        • apply
  2. 数组API:

    • 新增数组API
  3. 列表里引用:

5、ES6

  1. 列表项目

6、未完待续

7、闭包

相关文章
相关标签/搜索