TGViewer
JavaScript JavaScript @javascript · 31.1K subscribers
Post #2452 4.53K
CHALLENGE

const handler = {
get(target, prop) {
if (prop in target) {
return target[prop] * 2;
} else {
return `Property ${prop} not found`;
}
},
set(target, prop, value) {
if (typeof value === 'number') {
target[prop] = Math.round(value);
return true;
}
return false;
}
};

const obj = { a: 5, b: 10 };
const proxy = new Proxy(obj, handler);

proxy.c = 7.8;
proxy.d = "hello";

console.log(obj.c, proxy.a, proxy.x);
  • ❤ 2
More from @javascript
  1. Oct 4, 2026👀 Size Limit: A JavaScript Performance Budgeting Tool Set a size or load-time budget for…
  2. Oct 4, 2026Post #3536
  3. Oct 4, 2026CHALLENGE const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); co…
  4. Oct 3, 2026🤩 The Grand Unifying Architecture of Frontend SolidJS's creator argues that HTMX, React,…
  5. Oct 2, 2026😮 How Anthropic Made Claude's Apps 3x Faster in Two Weeks A grab bag of performance lesso…
  6. Oct 2, 2026Post #3532
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →