一、JS正则表达式
介绍:使用正则表达是的字符串的三个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的进阶用法
正则的进阶知识:
字符串的API
//普通用法
var str = "hello"
arr = str.split('')
console.log(arr)//['h','e','l','l','o']
//正则用法
var str = "hello world"
arr = str.split(/s/g)
console.log(arr)
二、面向对象
- 封装
- 继承
- 多态
三、原型链与作用域链
- 原型链
- 作用域链
四、ES5
-
严格模式:
- 严格模式的实现
1."use strict"
2.禁止给未声明的变量赋值
3.将禁默失败升级为错误
4.普通函数的调用中的this不在指向window,而是指向undefined -
ES5的对象保护
1.单个属性保护(1)访问器属性 (2)数据属性
2.对象结构的保护
(1)防扩展 (2)密封 (3)解冻
3.属性的分类
(1)命名属性 ——数据属性 ——访问器属性 (2)内部属性 ——class属性
4.替换this的三种方式
(1)call
(2)bind
(3)apply
- 严格模式的实现
-
数组API:
- 新增数组API
- 列表里引用:
五、ES6
- 列表项目