Aloha.zone.io

Aloha's technical notes.

View on GitHub

JavaScript

Advanced knowledge about JS

Useful APIs

Deep clone objects

Use new API structuredClone to deep clone the objects.

The best alternative of the old ways:

const deepCopy = structuredClone(obj)

const shallowCopy = { ...obj }

Performance

JSON.parse is faster than literal objects

Compare the two object assignment statements below, which is faster?

See this V8 blog, and the Chrome Dev Summit 2019

Reference

AST explorer