Skip to content

Instantly share code, notes, and snippets.

@gskachkov
Last active November 14, 2017 21:24
Show Gist options
  • Save gskachkov/e549eefef5a0271d310ec2aa97b82460 to your computer and use it in GitHub Desktop.
Save gskachkov/e549eefef5a0271d310ec2aa97b82460 to your computer and use it in GitHub Desktop.
const obj = {};
const proxy = new Proxy(obj, {
set: function (target, prop, value) {
if (prop === "id" && value === undefined)
throw new Error("'undefined' is not allowed.");
Reflect.set(target, prop, value);
return true;
}
});
proxy.id = "foo";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment