Created
November 9, 2017 19:39
-
-
Save gskachkov/442327a8c871207a1ae4c41c485783ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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