JavaScript 数组的深拷贝

0. 数组的深拷贝

方法一

a 数组连接 x 数组,并且返回一个新的数组

a.concat(x)

方法二:深拷贝(一层)

  1. 将所有可枚举的属性的值从⼀个或多个源对象复制到⽬标对象, 它将返回一个新对象
  2. 对于源对象里面的引用对象来说是浅拷贝,所以只有一层是深拷贝
  3. 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'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值