惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
量子位
T
Tailwind CSS Blog
T
Threatpost
The GitHub Blog
The GitHub Blog
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LangChain Blog
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
T
Troy Hunt's Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
T
Tor Project blog
T
The Blog of Author Tim Ferriss
I
Intezer
P
Privacy & Cybersecurity Law Blog
美团技术团队
N
Netflix TechBlog - Medium
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
Attack and Defense Labs
Attack and Defense Labs
T
Tenable Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Last Week in AI
Last Week in AI

小小孩

vaultwarden 部署 - 小小孩 前端项目路径别名终极解决方案 - 小小孩 去除宝塔面板一些无用的页面信息 - 小小孩 如何在 Bing 和 百度搜索中去除 CSDN 搜索结果 Nginx 安装 brotli 模块 - 小小孩 JavaScript 高性能现代网页截图 - 小小孩 http 协议头 Content-Disposition 的作用 - 小小孩 Echarts示例 Demo 合集网站 - 小小孩 LNMP Nginx 安装 brotli 模块
JS 深拷贝终结者 structuredClone - 小小孩
小小孩 · 2001-08-30 · via 小小孩
之前的 JS 数据深拷贝,都是要么递归要么是利用 MessageChannel 来实现深克隆,现在终结者来了,JS 原生支持的函数 structuredClone ,可以实现数据深拷贝

StructuredClone API

structuredClone 是结构化拷贝算法的实现,能够实现几乎对所有数据类型的深拷贝。

语法

structuredClone(value)
structuredClone(value, { transfer })

参数

  • value
    被克隆的对象。可以是任何结构化克隆支持的类型。
  • transfer 可选
    是一个可转移对象的数组,里面的 值 并没有被克隆,而是被转移到被拷贝对象上。

限制

但是也有一些限制

  1. 不允许克隆Error、Function和DOM对象,如果对象中含有,将抛出DATA_CLONE_ERR异常。
  2. 不保留RegExp 对象的 lastIndex 字段。
  3. 不保留属性描述符,setters 以及 getters(以及其他类似元数据的功能)。例如,如果4. 一个对象用属性描述符标记为 read-only,它将会被复制为 read-write。
  4. 不保留原形链。

兼容性

  • Chrome >= 98
  • FireFox >= 94