Tsallaka zuwa abun ciki
Justice Tech School

Modern Globals

Node has fetch, URL, AbortController, structuredClone, TextEncoder and more as globals.

Example
const a = { n: [1, 2], d: new Date(0) };
const b = structuredClone(a);
b.n.push(3);
console.log(a.n, b.n);
const ac = new AbortController();
console.log(ac.signal.aborted);
console.log(new TextEncoder().encode("hi"));

Result

[ 1, 2 ] [ 1, 2, 3 ]
false
Uint8Array(2) [ 104, 105 ]

Exercise

Deep copy.

(obj)

Quiz Test

What does structuredClone do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.