___  ___    _ _    _  _ _____   _____
 / __|/ _ \  | | |  | || |_ _\ \ / / __|
| (_ | (_) | |_  _| | __ || | \ V /| _|
 \___|\___/    |_|  |_||_|___| \_/ |___|

 --- A GOPHER-LIKE INTERFACE FOR HIVE BLOCKCHAIN ---

JavaScript Basics: Reflect

BY: @ghasemkiani | CREATED: Feb. 14, 2018, 7:40 p.m. | VOTES: 31 | PAYOUT: $7.37 | [ VOTE ]

Reflect is a global object in ES6 and later that provides the reflection API for JavaScript. Most strongly typed languages, such as Java, provide a reflection API which you can use to inspect and fine-tune the low-level structure of objects. Since JavaScript is a dynamic language, most of that functionality is already present in the language. However, Reflect provides a more meaningful place for these functionalities.

Reflect is not a function, so it is not callable (and it cannot be used with the new operator). It is just a global object and all its methods are static methods.

The methods of Reflect are the same methods that are available for ES6 proxies. However, proxies are not the subject of discussion in this post.

Here is a list of methods available from Reflect global object:

    defineProperty
    getOwnPropertyDescriptor
    getPrototypeOf
    setPrototypeOf
    preventExtensions
    isExtensible
    construct
    apply
    deleteProperty
    has
    ownKeys
    get
    set

Some of these methods are similar to the methods available on Object and have similar functions, albeit sometimes a little different. For example, Reflect.defineProperty has the same functionality as Object.defineProperty, except that it returns a boolean indicating whether or not the operation was successful, whereas Object.defineProperty returns the first argument as its return value.

Reflect.getOwnPropertyDescriptor works in the same way as Object.getOwnPropertyDescriptor.

Similarly, Reflect.getPrototypeOf works in the same way as Object.getPrototypeOf. However, for setPrototypeOf, the return value is different. Object.setPrototypeOf returns the given object, while Reflect.setPrototypeOf returns a boolean value indicating whether or not the operation was successful.

Reflect.preventExtensions works like Object.preventExtensions, except that if the given argument is not an object, it throws a TypeError. In the case of Object, the argument is coerced to an object. The same situation exists with isExtensible.

The rest of the methods will be discussed in future posts.

Related Posts

TAGS: [ #javascript ] [ #programming ] [ #technology ]

Replies

@andersonadeli | Feb. 14, 2018, 7:41 p.m. | Votes: 0 | [ VOTE ]

upvote and resteemit done dear....
keep it on....

@sarsey | Feb. 14, 2018, 7:42 p.m. | Votes: 1 | [ VOTE ]

Good job man......great working......great thinking...creative mind...keep it up!!!......

@steemibu351 | Feb. 14, 2018, 7:43 p.m. | Votes: 0 | [ VOTE ]

love to read it .........

@steemibu351 | Feb. 14, 2018, 7:43 p.m. | Votes: 0 | [ VOTE ]

fabulous one

@sportslover | Feb. 14, 2018, 7:43 p.m. | Votes: 0 | [ VOTE ]

i like this programming and good post about java script.... i just want to say that its good
....

@sabihaa | Feb. 14, 2018, 7:45 p.m. | Votes: 1 | [ VOTE ]

This is very helpful to learn java .Java is one of the most useful program.thank you

@smileplease | Feb. 14, 2018, 7:46 p.m. | Votes: 2 | [ VOTE ]

script>

var ghasemakiani ="Its really helpful post and
very powerful language will
be in 2018";

alert('ghasemakiani');

</script

@sharifulislamm | Feb. 14, 2018, 7:48 p.m. | Votes: 1 | [ VOTE ]

Thank you sir.I have a question.Before you have post 2/3 each day(idioms tutorial)
But now you have post so low number.

@ghasemkiani | Feb. 15, 2018, 6:37 p.m. | Votes: 0 | [ VOTE ]

Thank you @sharifulislamm. I am experimenting with new types of posts. I may have some other language-related posts in the future. Thank you for your interest and support.

@triptybarsha | Feb. 14, 2018, 7:49 p.m. | Votes: 1 | [ VOTE ]

Thanks for this programming sharing...... i appreciate this post. best of luck...

@juborajmollah | Feb. 14, 2018, 7:49 p.m. | Votes: 1 | [ VOTE ]

Very nice post...

@nnajmull | Feb. 14, 2018, 7:53 p.m. | Votes: 2 | [ VOTE ]

That's great gaming post. .Thanks for sharing ..

@barbie.doll | Feb. 14, 2018, 7:55 p.m. | Votes: 0 | [ VOTE ]

Thanks for sharing about javascript

@mdraba | Feb. 14, 2018, 8:03 p.m. | Votes: 1 | [ VOTE ]

Great post dear..I appreciate your post...Keep it up..

@mdraba | Feb. 14, 2018, 8:04 p.m. | Votes: 1 | [ VOTE ]

Resteemit done..

@followforupvotes | Feb. 14, 2018, 8:11 p.m. | Votes: 0 | [ VOTE ]

As a follower of @followforupvotes this post has been randomly selected and upvoted! Enjoy your upvote and have a great day!

@nishadhasan | Feb. 14, 2018, 8:27 p.m. | Votes: 1 | [ VOTE ]

Feeling happy that it begins again. Resteem done :D

@kain196 | Feb. 14, 2018, 8:47 p.m. | Votes: 0 | [ VOTE ]

Great job.Dear!!!!!

@agyapong | Feb. 14, 2018, 9:07 p.m. | Votes: 0 | [ VOTE ]

Great! great work

@jackjounior | Feb. 14, 2018, 9:13 p.m. | Votes: 1 | [ VOTE ]

javascript is awsome language,carry on

@princeparvej | Feb. 14, 2018, 9:17 p.m. | Votes: 0 | [ VOTE ]

thnkas for sharing it .java script is awsome

@haji | Feb. 14, 2018, 10:50 p.m. | Votes: 1 | [ VOTE ]

nice post bro

@angela.ghkh | Feb. 14, 2018, 10:54 p.m. | Votes: 1 | [ VOTE ]

oh , thanks so much for sharing this info
.. so.. is it true that we can not create a new object from them cause they are static? and... is it true if i say reflect is as like as property ?

@ghasemkiani | Feb. 16, 2018, 3:06 a.m. | Votes: 0 | [ VOTE ]

Yes. Reflect is a global object like Math.

@kazmi1 | Feb. 15, 2018, 2:19 a.m. | Votes: 1 | [ VOTE ]

nice post.java is a good language.

@nimik | Feb. 15, 2018, 3:46 a.m. | Votes: 1 | [ VOTE ]

Nice post.

@borlan | Feb. 15, 2018, 8:15 a.m. | Votes: 0 | [ VOTE ]

Very useful post.

@zpzn | Feb. 15, 2018, 9:21 p.m. | Votes: 1 | [ VOTE ]

Mamnunam az lotfetun aghaye ghasemkiani :) 🙏

@ghasemkiani | Feb. 16, 2018, 3:05 a.m. | Votes: 0 | [ VOTE ]

خواهش می‌کنم. موفق باشید.

@zpzn | Feb. 16, 2018, 7:23 a.m. | Votes: 1 | [ VOTE ]

Sepaas

@diego18 | Feb. 15, 2018, 9:27 p.m. | Votes: 1 | [ VOTE ]

Hello friend, this contribution of JavaScript is very good for our learning thanks for sharing.[IMAGE: https://steemitimages.com/DQmcmDqfgTEaan22PMzEtf7EwdrSic2TJPp5h4B9DfQRnVW/Desarrollo.jpg]

@divaa | Feb. 16, 2018, 5:38 a.m. | Votes: 0 | [ VOTE ]

Good Post.

@sam1210 | Feb. 16, 2018, 9:10 a.m. | Votes: 1 | [ VOTE ]

nice to see your blog about programming again.

@plainoldme | Feb. 19, 2018, 7:21 a.m. | Votes: 0 | [ VOTE ]

another good lesson in javascript, thanks for the post, really learning some nice javascript coding from you.

@steamit2 | Feb. 19, 2018, 7:25 a.m. | Votes: 0 | [ VOTE ]

thank you for all your good post on the javascript, Reflect really helps

@steamit2 | Feb. 19, 2018, 7:32 a.m. | Votes: 1 | [ VOTE ]

thanks, i'm used to old plain javascript, but this is something else, will definitely help me with my coding, thanks for the post

@alok1 | July 4, 2018, 1:42 p.m. | Votes: 0 | [ VOTE ]

Need your support sir. Please.

[ BACK TO TRENDING ] [ BACK TO MENU ]
CMD>