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.
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 toFunction.prototype
object. 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.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you for your informative reply.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I didn't understood
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Informative post.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good post, thanks for sharing this post.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
nice post bro
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Have a nice day sir, Stay safe.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hi I'm duma, I'm calling from Indonesia :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
sir as a new steemers i want your help by my post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Looks like i still need to learn a lot of programming :)
but many thanks for sharing it
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I am not so good in javascript but this is informative 😊
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
great post, ghasemkiani as usual!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
person.speak("thanks for the post, this will Reflect in future coding of mine");
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
مشتی ساپورت ♥
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
another interesting information about reflect , thanks
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
cool post. i am also a js developer from time to time
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
it's very informative post.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
That's a great gaming programming...Keep it up...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
it so helpful post for us......
thanks for sharing.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
well thanks for sharing .. learning have a nice day bro
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
That's a great and outstanding programming ..Resteemit done..
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
well wrote dear @ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks for share JavaScript
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
nice program. i like it
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you for sharing and teaching others sir..
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Your information is very useful, the work you do is very meaningful, I really appreciate post @ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@ghasemkiani Good tutorial. I just love this. Thanks for sharing.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
you are a good javascript programmer. well done @ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Carry on your activitys
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good post..Keep it up..
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Nice post sir.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
very well post dear friend @ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
nice post...thanks for share
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
great
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Nice Post ..
Followed you..
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
javascript is a advance programming language . i try c language as a begainer
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Like back
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Upvote and resteemit...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
This is my favorite javascript...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
add-on on the Reflect post, thanks,
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks for this post, very informative i hope you keep sharing with us all your knowledge
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I always follow your post everything is good if any time visit my blog @mamaathiyya
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
its the bleesing of science.and
important also...
carry on please.
i will wait for your next info....
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
its a great info.i really praise your activity..
many thanks for sharing us...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
This nice post iappreciate your programming thanks for sharing this technology..Carry on..
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks for sharing this post.
I appreciate your every post ..Best of luck.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit