TGViewer
JavaScript JavaScript @javascript · 31.1K subscribers
Post #2529 4.79K
CHALLENGE

const target = { name: 'Sarah', age: 25 };

const handler = {
get(obj, prop) {
if (prop in obj) {
return obj[prop];
}
return `Property '${prop}' not found`;
},
set(obj, prop, value) {
obj[prop] = value.toString().toUpperCase();
return true;
}
};

const proxy = new Proxy(target, handler);
proxy.city = 'boston';
console.log(proxy.name);
console.log(proxy.city);
console.log(proxy.country);
  • ❤ 5
  • 🔥 2
More from @javascript
  1. Oct 3, 2026🤩 The Grand Unifying Architecture of Frontend SolidJS's creator argues that HTMX, React,…
  2. Oct 2, 2026😮 How Anthropic Made Claude's Apps 3x Faster in Two Weeks A grab bag of performance lesso…
  3. Oct 2, 2026Post #3532
  4. Oct 2, 2026CHALLENGE const arr = [1, 2, 3]; const log = []; const result = arr.map((x, i) => { if (i…
  5. Oct 1, 2026Post #3530
  6. Oct 1, 2026CHALLENGE class Counter { #count = 0; static #instances = 0; constructor() { Counter.#inst…
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 →