- Joined
- Feb 12, 2020
- Messages
- 8
- Reaction score
- 0
I can't seem to find how to best use proxy in javascript to watch objects for changes. An example is how do i delete a proxy after i am done using it? is it as simple as using "delete"?
I don't know what your talking about with the word PROXY. If you want JS to watch an object for changes I would use a listener
document.getElementById("myDIV").addEventListener("mousemove", myFunction);
and remove it with
document.getElementById("myDIV").removeEventListener("mousemove", myFunction);
var object = {a:1,b,2};
var proxy = new Proxy(object,{
get:function(obj,prop){
},
set:function(obj, prop, value){
}
});
pdiddles I am asking you for help now. Back in 2015 I studied everything new in ES6. I came away with the notion they were trying to become C and that there was a lot of BS in the new spec. "let", for example. "proxy" must have been labeled - worthless in my mind and until now have never seen it in any program.
I have reread a lot of articles on what it does and how, but still have no reason where this could be used nor why it should be used. So that is my question to you. Enlighten me please. Give me some examples.
for(var i = 0; i < 5; i++){
}
console.log(i)
for(let i = 0; i < 5; i++){
}
console.log(i)
OK, understood. Not my cup of tea.
I mean things like proxy isn't my cuppa. Can think of other ways of doing this with JS. Nice thing about the language is you have a choice on how you do things. ES6 gave us some nice things and some that are not so nice; nor are they upgrades.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.