Skip to content

Instantly share code, notes, and snippets.

@gskachkov
Created November 9, 2017 19:39
Show Gist options
  • Save gskachkov/442327a8c871207a1ae4c41c485783ba to your computer and use it in GitHub Desktop.
Save gskachkov/442327a8c871207a1ae4c41c485783ba to your computer and use it in GitHub Desktop.
var target = { id: "id-0" };
var handler = {
set: function (target, property, value, receiver) {
if (property.charAt(0) === "_") return false;
target[property] = value;
return true;
}
};
var proxy = new Proxy(target, handler);
proxy.id = "value-1";
proxy._id = "value-2";
console.log(proxy); // { id: "value-1" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment