A Practical Guide to JavaScript Proxy Objects

preview_player
Показать описание
Have you ever wondered what proxies are in JavaScript and what you can use them for? In this video, we take a look at Proxy Objects in JavaScript. We start off by creating our own implementation of the proxy, then dive into a practical application for proxies.

🌎 Follow me here:
Рекомендации по теме
Комментарии
Автор

Tom you always have great content. Came across JS Proxy today and needed to understand it. Checked a few videos but this was the best. Tom always saves the day!

Dave-dley
Автор

naming the proxy getCharacter is kinda rough, it really undermines the understanding. Calling it "characterProxy" would make vastly more sense, esp. as you expand the functionality of the proxy.

Secondly, it may be a matter of form, but I would always use target instead of the original object when using the proxy. I think proxies are recursive, so you can proxy a proxy etc... one of your implementations refered to the original object directly, bypassing future flexibility.

all-in-all a decent run through, with just those minor nit picks.

prozacgod
Автор

Good video, nice to here an Australian voice instead of always American voices

hermana
Автор

Thank u for this guide, tho i have a question. Why write 'complicated' proxy obj instead of a function which will check if an item with ID passed to our fetch function already exists in our cache? and just return if it does?

matecode
Автор

This is a good explanation thanks for that, but why would be one using this approach of getter and setter isn't this approach more relevant towards object oriented whereas JS is functional ?

SachinYadav-ehvg
Автор

13:17 don't need the Boolean just to wrap it in ( )

koi
Автор

How you set the value, if handler dosent have the set mothod... ??? 😵‍💫

alexanderdiakonov
Автор

This is actually bad
Don't recommend watching it, you'll ruin your understanding of the purpose of proxies

Great channel overall, but this video is bad

I'm sorry

AndRuz
Автор

All you need to get the `in` operator working is the grouping operator.

if( !(1 in getCharacter)) {

}

It is not the case that:—

if( !1 in getCharacter)

— is falsey all the time. `!1` is converted ToBoolean to false. Thus, the expression is literally evaluated as:—

if(false in getCharacter)

— and, given that id's are numeric here, `false in getCharacter` will literally be false all the time.

supremoluminary