正在加载视频...
视频加载失败
This is one you need to know. JS has a built-in function for deep cloning objects called `structuredClone`, which can handle: 😍 Deeply nested objects and arrays 🌎 Many types, like Date, Set, Map, etc ➰ Circular references More in my latest article:
10 条评论

More on what `structuredClone` can do, and how it compares to alternatives, in my latest post:

Unfortunately it’s comparatively pretty slow & relatively new so a significant portion of audiences can’t support it. is 500b at heaviest and extremely fast.

ugh we still need to implement this in bun

I see the double JSON move in so many old code bases. Would this be worthy of a pull request or would I probably just annoy the maintainers?

Good Q. There are some minor but notable differences, like JSON is a little faster in some cases, and structureClone will throw errors for some things JSON won’t and visa versa, and handling some types like undefined are different. Probably safest to not semi blindly swap

Js has the most random standard library

structuredClone also supports ArrayBuffers, Streams, etc... but, unfortunately you have to manually list them out as transferable objects for it to work, that's where `transferables` comes in, it makes it fast and easy to use transferable objects

Thanks for highlighting this. Reading up, I found these note on its limitations interesting too:

Awesome tip Thanks !!!!

Actually not bad..
相关视频
Awesome new cmdlet from You can now navigate nested objects interactively!
Steve Lee
20,767 次观看 • 2 年前
Sensitive content
"If you don't have a deep and instinctual contempt for women in general, you are not going to make it" We need a patriarchy. Women need to be objects not subjects
1stclassclips
194,500 次观看 • 4 个月前
