setintermediateconst log = []
const p = new Proxy({}, {
set: (t, k, v) => { log.push(String(k) + '=' + v); t[k] = v; return true }
})
p.x = 10
console.log(log) // β ["x=10"]The set trap intercepts property assignments on a proxy, letting you validate or observe writes before they reach the target.
Use the set trap to store a transformed version of the value.
Challenge: Verify that after p.n = 5, reading p.n returns 10 (value doubled).