JavaScript ES6 Reflect Object

  Рет қаралды 11,477

Steve Griffith - Prof3ssorSt3v3

Steve Griffith - Prof3ssorSt3v3

Күн бұрын

This tutorial explains what is and how to use the ES6 Reflect Object which allows you to dynamically intercept Object property and method operations
Typically Reflect gets used in conjunction with Proxies.
Code from Video: gist.github.co...

Пікірлер: 40
@hmodarres
@hmodarres 2 жыл бұрын
the video didn't motivate it enough, i still don't understand how setting a "a.b" property like "a.b=3" at runtime is any less "dynamic" than doing it with Reflect
@karthickchandiran2397
@karthickchandiran2397 4 жыл бұрын
first time i am seeing this.but i didn't the purpose of this reflect.becuase we can do all the above operation with Object itself.
@aamirjamal6833
@aamirjamal6833 4 жыл бұрын
Same here.
@ProfessorSyndicateFranklai
@ProfessorSyndicateFranklai 4 жыл бұрын
It's kind of esoteric, but there is a pretty good stackoverflow answer (all the way back from 2014!) that I think addresses some key points. For most basic operations, I suspect you may never have to use it, but it's one of those niche specialist tools in your toolbox that'll make life just a little easier when you need it. stackoverflow.com/questions/25421903/what-does-the-reflect-object-do-in-javascript Basically, Reflect is good for exceptionless handling, variable constructor arguments in ES5, setting the 'this' in some function calls, and generally avoiding older and uglier code. Oh, and proxies too.
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
@@ProfessorSyndicateFranklai thanks for posting this.
@meduzfr
@meduzfr 4 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 Thank you for the link, Francis! Steve: It’s very easy to understand Reflect syntax and you explain it very well, but I think the lack of explanation about its purpose will make most people thinking that “you can do the same with Object” is the only takeaway to get here.
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
@@meduzfr this video is really just a precursor to my video on proxies.
@pronayguha7099
@pronayguha7099 4 ай бұрын
Steve, does it really add the new attribute to the object itself, or it's another copy of the same object ?
@_Redu
@_Redu 2 жыл бұрын
Sorry but this is just trash..! You don't explain why exactly you are using the Reflect object instead of using the equilavent functionalites directly available on the subject object. I mean why exactly you need to use Reflect.get(myObject, "name") instead of myObject.name or myObject["name"]?
@pandasoli6581
@pandasoli6581 Жыл бұрын
wbu defineMetadata and setMetadata?
@LR-bc8js
@LR-bc8js Жыл бұрын
Great video as usual! However, I still don't understand what's the need of Reflect when we can do everything with objects?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 Жыл бұрын
Reflect typically gets used with Proxy Objects. Proxy objects can be used like a standard interface wrapped around many different objects, handling and controlling access to each object. Reflect lets you easily target the specific object that you targeting. Similar to using `this` but in a more standard way that avoids differences in scope, which would alter the value of `this`.
@LR-bc8js
@LR-bc8js Жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 Make sense! Thank you!
@tankbottoms-yes
@tankbottoms-yes 4 жыл бұрын
I’m trying to figure out how to keep track of a series of object transformations and data processing steps and it seems to me I could use Reflect to keep an array of functions to do these transforms and during some node-cron period call, iterate over the objects, call the Reflect object to check what transform function pointers need to be called and run them. Does this sound like a reasonable pattern?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
Reflect is not really a storage mechanism to hold lists of anything. It is a way to dynamically access an object's properties or methods. You can intercept the calls. You can delegate the calls too. Proxies also can work in combination with the reflection. I will have a video on that coming soon.
@hanjelly5410
@hanjelly5410 2 жыл бұрын
Nice, thanks for this summary, just an update the latest MDN doc to delete an property is changed to `Reflect.deleteProperty()`.
@Youssef-lv6wp
@Youssef-lv6wp 4 жыл бұрын
First view Thanks u ❤
@johnm8358
@johnm8358 4 жыл бұрын
I don't get the use of this when I can do all that without reflect
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
See the comment by Francis Lai for the answer
@nigelbrie5693
@nigelbrie5693 3 жыл бұрын
"JavaScript From The Start" I DID IT! I completed the entire series. Thank you Steve for the many hours of valuable knowledge you have given me!! Where do I go now to complete my certificate? lol
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
Lol. Now go through the JavaScript in the Browser list and the APIs and AJAX playlists. Then server-side with PHP, MySQL, Node, and Express. Then the React and React Native playlists.
@nigelbrie5693
@nigelbrie5693 3 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 This is so daunting! I can't imagine making this many videos let alone learning all of this. 185 on that first list!
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
@@nigelbrie5693 no worries. I'll extend your deadline by a couple weeks. 🤪
@mod7ex_fx
@mod7ex_fx 2 жыл бұрын
((:: thank you my teacher
@abdallaabbass4271
@abdallaabbass4271 4 жыл бұрын
Thanks very much, really you are my best teacher ❤️❤️❤️
@chesterxp508
@chesterxp508 2 жыл бұрын
Another very cool tutorial!
@janduna9187
@janduna9187 3 жыл бұрын
Is the proxy video out ? I was unable to find it on his channel :(
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
Not yet. :( Soon I hope.
@hamidallah
@hamidallah 4 жыл бұрын
Thank you sir
@markleodionisio2669
@markleodionisio2669 4 жыл бұрын
Thanks for sharing master.
@shajanjp
@shajanjp 4 жыл бұрын
Thank you ❤️
@karimnassir5207
@karimnassir5207 4 жыл бұрын
Why a , b equal name and id in the object ?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
The arguments that I passed to the function was the Array generated with Reflect.ownKeys
@nagendrapp2213
@nagendrapp2213 4 жыл бұрын
could you please create some projects using js and REact
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
I have a playlist of videos on React - kzbin.info/www/bejne/rIWph5psfpeqhKs
@nagendrapp2213
@nagendrapp2213 4 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 i have seen you have already a playlist But i want to you Create a some complex applications if possible could you please create some advanced Projects : )
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
@@nagendrapp2213 Please post any tutorial requests in the comments here - kzbin.info/www/bejne/gnTIq5SuZ9qBacU
@slmshady539
@slmshady539 3 жыл бұрын
Hey steve I have learnt a lot from you and would like to recommend you something, why don't add more videos to series JS Interview and make that playlist as one-stop for everything javascript.
Promises and the allSettled Method
7:42
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 6 М.
Actual use case for JavaScript PROXY!
13:09
Kevin Ghadyani - JavaScript
Рет қаралды 13 М.
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 4,5 МЛН
Как мы играем в игры 😂
00:20
МЯТНАЯ ФАНТА
Рет қаралды 3,2 МЛН
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,8 МЛН
Что такое ПРОКСИ в JavaScript (Proxy)
10:11
Веб-разработка - DevMagazine
Рет қаралды 10 М.
Weak References, Reachability, WeakSets, and WeakMaps
15:54
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 3,8 М.
JavaScript Proxies
22:54
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 11 М.
Интроспекция и рефлексия в JavaScript
1:02:33
Timur Shemsedinov
Рет қаралды 6 М.
Immutability in JavaScript
15:13
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 7 М.
A Practical Guide to JavaScript Proxy Objects
14:19
TomDoesTech
Рет қаралды 7 М.
JavaScript Metaprogramming - Dave Fancher - NDC London 2022
58:26
NDC Conferences
Рет қаралды 4,5 М.
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 4,5 МЛН