so proxies what are they well if you've anytime worked with getters and setters
proxies are that way yet like getters and setters on steroids are overhauled with extra components it's a way that you can create something going to get any sales for properties or the potential gains of properties then again in the event that you genuinely want to revive a property or, again to call one more capacity this will continue like an interceptor it will be something in between so the singular makes the choice makes proper acquaintance give me the value of that thing you can do data endorsement on it you can return something completely different you can throw botches from this thing perpetually stacks of possible results so crucial etymological construction we ought to bounce into that that will make things fundamentally more clear I have a fundamental thing here and I will make a regulator article and this thing here my regulator this is where I will put the code so there will be inside here a property called get and this will be an ability and there will be another property called set I don't should have both yet generally you will have the two things so like I said before a getter and a setter and we make the middle person by calling new delegate and a short time later we elapse in our ideal thing to screen this one here and subsequently the supervisor this is the catch this' getting the calls the singular will be working with this thing here the mediator object so that is the one that you would uninhibitedly reveal and get people to use in the code or you would use in the code is the mediator object inside the get and the set we have two or three properties that will be passed in here for us the objective this will be the thing here there will be prop so the thing property are you alluding to which while you're endeavoring to get or set there's a third property which actually the mdn documentation for new mediator itself for calling this technique doesn't really determine in the model the manner that there's this third property that is how little it's used at this point it is there the beneficiary will be a reference to the go-between object itself could we copy that here so same thing and get and set we have target property and gatherer so target and property those are the two things that we will work with and the get is the catch whenever you endeavor to recuperate the value so here i'm calling proxy.prop now right now this code is doing nothing in any way shape or form and if my manager in a brief kill these could we basically comment them out assuming I some way or another ended up running this code right now I get the main characteristics my regulator is an unfilled thing so the requesting for prop 1 and prop 2 they're a pass through they go directly to the primary thing and get those values now with my get and set up here we will catch we will trap the require these things we ought to do the get first we can say that I want to recuperate so I will check and guarantee when somebody asks me for a property I will look and see hi inside that one of a kind article do I have something by that name does it exist expecting this is the case exceptional I will return it so we can say return target prop else I can return something I can throw a bungle so I'm going to right as of now return a message like that at present down here I'm mentioning prop 1 prop 2. I will change this to prop 1 and prop 3. There is no such thing as prop 3 at present inside here there's simply prop 1 and prop 2. so I should see prop 1 return the greeting and a short time later I should see no such property we are not too far off so hey and no such property so we're catching this and we can figure out whether there was something there or maybe there's some default regard so when my regulator you know precisely has no effect what it is I can do this so I can return something along those lines and it is not too far off so my supervisor can have default values to use as contingency plans in case I really want or we might I at any point will throw an error so as opposed to returning a value I will throw a bumble and my bungle will be no such prop same sort of figured basically a substitute way to deal with doing this and here it will come up I could wrap there's my sort botch I could wrap the call to this inside an endeavor get and subsequently in my catch I would get that screw up and I could oversee it do anything I want with it anyway you can see with the get we're getting the ability to start truly taking a gander at these things and maybe before I return a veritable property what I accept that ought to do is I want to express OK to do something to it so I will take the value and I will endorse it so we could take this value we could confirm whether it's a number or a letter a string or a number rather could we comment this one out considering the way that we needn't bother with that bumble there we are we've advanced the value returning same idea over in set we can check whether we really want to reproduce how you would oversee object seal so i'm holding new properties back from being added so expecting the property exists fine I will express we're going to return certified certainly go ahead and do that um to throw a bumble maybe i'm going to the return there is probably the best thing to do here and to make the set run as opposed to resolving these characteristics as we're doing here we genuinely would finish something like this so delegate bit prop 1 and we would it be advisable for us we ought to achieve something totally new for that and a short time later for a property that doesn't exist there we go so we've revived property one yet property three we're getting the mix-up back to make proper acquaintance you can't revive a property that doesn't exist so we're to some degree repeating how you would oversee object.seal to thwart things being added to an article OK so there's the fundamental syntax we have get we have set there are furthermore several distinct procedures you can check you can manufacture a catch for has for delete property you can develop one for capacities now four abilities here accepting I was building a catch for capacities I can't pass in an article that encapsulates abilities and do that I really need to pass in the real capacity and a while later the regulator will include a property inside it called apply and that apply will be the capacity this one doesn't get used so a ton yet it is there I will leave a little illustration of it in the record here if you peer down in the portrayal there's an association with the code that has all the code from this article and i'll leave a little representation of the capacity inside that one OK so that is the key language structure at present I will comment all of this out and let that fall down a bit get into a second model you can accepting that you want like right now my article is in a comparable degree as my manager and my middle person assuming I held onto any craving to go into the thing I can do it's given that I go through the mediator like we were here that i'm genuinely getting into that article and finishing things to it if I just clearly access obj.prop 1 or prop 2 I am dealing with that extraordinary article so there will be circumstances where you want to defend that remarkable article you would prefer not to achieve something we can use an unsafe immediately gathered ability verbalization one of these things where inside it I will run an ability that takes an article and puts it inside there so assume my obj that I get back this will be the go-between I won't see the first so accepting I took this and I passed it in to my hazardous this is my capacity like this and it will recognize we ought to consider it my obj this thing here will be passed into this variable and thereafter inside here what I will return is my delegate and it will take that article and thereafter there will be the regulator and what i'm returning is the middle person so this will be the middle person for this thing inside here we'd make our regulator same as we did before and have our get with the goal and the prop we have our set capacity with the goal and prop excessively same as we did in the main models a lot of that way and a short time later you can return anything that you really want so this is a way that you can use a covering rapidly in summoned ability explanation to protect the principal thing so another possible accentuation for you is doing that another practical model something that I think will be of worth if you're engaging still to fathom when or why you would accept ought to do this well json data is something that we'll regularly recuperate from a programming connection point maybe you accept ought to do endorsement on that data as it's being gotten so we can do that with our proxies I will make here something many allude to as articles guess that this is the data that got back from my server so I have a whole series of articles inside here to have a couple of data i'll say there's an id and a name there we go so we have different articles guess this was eliminated from json we finished a programming point of interaction hit we up brought some json use json.purse to change it into this range of things so I have a variable yet maybe this variable is close by in expansion to my capacity after my capacity is done this variable moves disposed of so I at absolutely no point in the future have the first and that is fine what I really want to have is the delegate object so we will do this my things I will overwrite them or I can make another thing and return that another group rather and return that yet I will overwrite it this and well actually of thing maybe each and every one of these.