0. 数组的深拷贝
方法一
a 数组连接 x 数组,并且返回一个新的数组
a.concat(x)
方法二:深拷贝(一层)
- 将所有可枚举的属性的值从⼀个或多个源对象复制到⽬标对象, 它将返回一个新对象
- 对于源对象里面的引用对象来说是浅拷贝,所以只有一层是深拷贝
- arr 和 arr2 相同的对象将合并, 后者覆盖前者
object.assign({},arr,arr2)
方法三:JSON.parse() 和 JSON.stringify()直接进转化
对象里面的 函数
, 将无法转化, 被移除
copyObj2 = JSON.parse(JSON.stringify(srcObj));
1. if 条件判断几种false情况
- False: 0、-0、0.0、null、“”、‘’、false、undefined、NaN
- True: {}、[]
空数组, 空字典, 空集合为 True, 其他为空, 为空字符, 为 0, 未定义都是 False
2. 网页编辑模式
document.designMode
controls whether the entire document is editable. Valid values are “on” and “off”. According to the specification, this property is meant to default to “off”. Firefox follows this standard. The earlier versions of Chrome and IE default to “inherit”. Starting in Chrome 43, the default is “off” and “inherit” is no longer supported. In IE6-10, the value is capitalized.
window.document.designMode='on'