Phone Number Proxy

const phoneHandler = { set(target, name, value) { target[name] = value.match(/[0-9]/g).join(''); } get(target, name) { return target[name].replace(/(\d{3})(\d{3})(\d{4})/, '($1)-$2-$3'); } } const phoneNumbers = new Proxy({}, phoneHandler);
A proxy for handling janky phone numbers

1 Response

There is some error in the code. Fix them.

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.