___|  _ \   |  |    |   |_ _|\ \     / ____|
 |     |   |  |  |    |   |  |  \ \   /  __|
 |   | |   | ___ __|  ___ |  |   \ \ /   |
\____|\___/     _|   _|  _|___|   \_/   _____| 

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

JavaScript Basics: Reflect.apply

BY: @ghasemkiani | CREATED: Feb. 16, 2018, 3:08 a.m. | VOTES: 43 | PAYOUT: $6.85 | [ VOTE ]

The method Reflect.apply is just a better and more meaningful way to do Function.prototype.apply. In other words, it allows you to call the given function using a specified context (this argument) on an array of arguments. Here is an example:

    let person = {
        name: "John",
        speak(city) {
            console.log(`Hi. I am ${this.name}. I am calling from ${city}.`);
        },
    };

    let someone = {
        name: "Jack",
    };

    person.speak("Houston");
    // Hi. I am John. I am calling from Houston.

    Reflect.apply(person.speak, someone, ["Boston"]);
    // Hi. I am Jack. I am calling from Boston.
    person.speak.apply(someone, ["Boston"]); // the same
    Function.prototype.apply.call(person.speak, someone, ["Boston"]); // the same

As I said in an earlier post, the Reflect object gathers all functionality related to reflection in one place. This makes it possible to write neater and more readable code.

Related Posts

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

Replies

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

Thanks for sharing this post.
I appreciate your every post ..Best of luck.

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

Thank you for sharing and teaching others sir..

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

Thanks for giving us a new topic.It is an educative value for us.We can get many concept about javascript,programming & so on.
Thanks
@Ressteem,upvote & follow done.

@dumasari | Feb. 16, 2018, 3:11 a.m. | Votes: 1 | [ VOTE ]

Hi I'm duma, I'm calling from Indonesia :)

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

I always follow your post everything is good if any time visit my blog @mamaathiyya

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

This nice post iappreciate your programming thanks for sharing this technology..Carry on..

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

Thanks for this post, very informative i hope you keep sharing with us all your knowledge

@mdraba | Feb. 16, 2018, 3:14 a.m. | Votes: 1 | [ VOTE ]

That's a great gaming programming...Keep it up...

@beautybox | Feb. 16, 2018, 3:14 a.m. | Votes: 1 | [ VOTE ]

programing is a language of computer you input this his language and its output your language
now its a very important in every sphere
carry on

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

Upvote and resteemit...

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

Like back

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

javascript is a advance programming language . i try c language as a begainer

@rrahim | Feb. 16, 2018, 3:27 a.m. | Votes: 1 | [ VOTE ]

That's a great and outstanding programming ..Resteemit done..

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

Good post..Keep it up..

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

Carry on your activitys

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

thanks for your educative blog...
best of luck....

@steemitservice | Feb. 16, 2018, 3:31 a.m. | Votes: 1 | [ VOTE ]

well thanks for sharing .. learning have a nice day bro

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

Thanks for share JavaScript

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

Your information is very useful, the work you do is very meaningful, I really appreciate post @ghasemkiani

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

nice post...thanks for share

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

This is my favorite javascript...

@nazira | Feb. 16, 2018, 4:08 a.m. | Votes: 0 | [ VOTE ]

well wrote dear @ghasemkiani

@nimik | Feb. 16, 2018, 4:33 a.m. | Votes: 1 | [ VOTE ]

Good post, thanks for sharing this post.

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

nice program. i like it

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

it so helpful post for us......
thanks for sharing.

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

Informative post.

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

@ghasemkiani Good tutorial. I just love this. Thanks for sharing.

@killerkuasha | Feb. 16, 2018, 6:25 a.m. | Votes: 1 | [ VOTE ]

it's very informative post.

@expertroyal | Feb. 16, 2018, 6:43 a.m. | Votes: 0 | [ VOTE ]

you are a good javascript programmer. well done @ghasemkiani

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

Last line is really interesting...
Function.prototype.apply.call
Was not aware it works that way. Actually:

Function.prototype.call === Function.prototype.bind.call.apply.bind.call

So it seem that Function.prototype functions (Function.prototype.bind, Function.prototype.call, etc.) do have object linkage to Function.prototypeobject. We can even access such linkage. See here:
Function.prototype.apply.__proto__ === Function.prototype

That's why we can chain it deeply. Really interesting. Also was not aware of such Reflect feature. Thanks for sharing.

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

Thank you for your informative reply.

@haji | Feb. 16, 2018, 8:12 a.m. | Votes: 1 | [ VOTE ]

nice post bro

@nanu1 | Feb. 16, 2018, 8:40 a.m. | Votes: 1 | [ VOTE ]

Nice post sir.

@alimuddin | Feb. 16, 2018, 8:48 a.m. | Votes: 0 | [ VOTE ]

very well post dear friend @ghasemkiani

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

Have a nice day sir, Stay safe.

@agyapong | Feb. 16, 2018, 9:20 a.m. | Votes: 0 | [ VOTE ]

great

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

Nice Post ..
Followed you..

@saddam1210 | Feb. 17, 2018, 4:32 a.m. | Votes: 1 | [ VOTE ]

sir as a new steemers i want your help by my post

@angela.ghkh | Feb. 17, 2018, 8:42 p.m. | Votes: 1 | [ VOTE ]

another interesting information about reflect , thanks

@blazing | Feb. 18, 2018, 6:21 a.m. | Votes: 1 | [ VOTE ]

Looks like i still need to learn a lot of programming :)
but many thanks for sharing it

@five34a4b | Feb. 18, 2018, 7:55 p.m. | Votes: 1 | [ VOTE ]

great post, ghasemkiani as usual!

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

add-on on the Reflect post, thanks,

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

person.speak("thanks for the post, this will Reflect in future coding of mine");

@haji | Feb. 19, 2018, 6:41 p.m. | Votes: 1 | [ VOTE ]

مشتی ساپورت ♥

@riyad11 | Feb. 20, 2018, 3:36 a.m. | Votes: 0 | [ VOTE ]

its the bleesing of science.and
important also...
carry on please.
i will wait for your next info....

@malibeauty | Feb. 20, 2018, 3:37 a.m. | Votes: 0 | [ VOTE ]

its a great info.i really praise your activity..

many thanks for sharing us...

@safamarwa | Feb. 20, 2018, 7:01 p.m. | Votes: 2 | [ VOTE ]

I didn't understood

@madiha | Feb. 21, 2018, 10:23 a.m. | Votes: 1 | [ VOTE ]

I am not so good in javascript but this is informative 😊

@ai-crypto-tech | March 2, 2018, 10:16 p.m. | Votes: 1 | [ VOTE ]

cool post. i am also a js developer from time to time

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