¶实现深拷贝, 思路: 判断待拷贝的属性是否为数组或对象然后递归
1 | function deepCopy (p, c = {}) { |
¶typeof
- ‘number’
- ‘string’
- ‘boolean’
- ‘undefined’
- ‘null’
- ‘symbol’
- ‘object’
- ‘function’
其中数组和对象都会返回 ‘object’
¶instanceof
1 | [] instanceof Array //true |
¶Object.prototype.toString.call
1 | Object.prototype.toString.call([]) // '[object Array]' |