__________     __ __     __  _______    ________
  / ____/ __ \   / // /    / / / /  _/ |  / / ____/
 / / __/ / / /  / // /_   / /_/ // / | | / / __/
/ /_/ / /_/ /  /__  __/  / __  // /  | |/ / /___
\____/\____/     /_/    /_/ /_/___/  |___/_____/

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

JavaScript Basics: Reflect.construct

BY: @ghasemkiani | CREATED: Feb. 16, 2018, 3:02 a.m. | VOTES: 30 | PAYOUT: $6.25 | [ VOTE ]

The method Reflect.construct helps construct a new instance from a constructor function given an array of arguments. It has a functionality similar to the new operator:

    function Employee (firstname, lastname) {
        this.firstname = firstname;
        this.lastname = lastname;
    }

    let employee1 = new Employee("John", "Doe");
    let employee2 = Reflect.construct(Employee, ["Jane", "Doe"]);

    // This can also be done with the spread operator:
    let args = ["John", "Smith"];
    let employee3 = new Employee(...args);

It is generally useful to have an alternative for the new operator, specially when we have an array of arguments. Even though this particular problem has been alleviated in ES6 with the introduction of the spread operator(...). (See the last line in the example code above.)

Related Posts

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

Replies

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

thank you D:@ghasemkiani
please come on my blog

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

This very nice post i appreciate your technology thanks for sharing ..Best of luck ...resteemit..

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

Good work.. You are writing nice and doing good for community.. I always told that computer is not my subject but always happy to see good work here.. And respect good teachers also

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

Thanks for sharing programming .
I appreciate this technology .
Best of luck.

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

programing is a language of computer.i like this specialy,mathlab,fortan,c/c++.excelent
thanks for sharing

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

Wow amazing programming...thaNks for sharing...

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

I like this post..
Resteemit done...

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

That's a great javascript...I like this post...

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

wow! amazing programming..thanks for shairing@ghasemkiani. have a nice day

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

Resteemit done..Sir..

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

this is very informative blog .thanks to you for sharing..i praise
you..
Carry on

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

come on my blog

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

Good information about reflect construct in javascript. You are guiding us like a teacher
Thank you very much @ghasemkiani

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

I like this programming..Keep it up..

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

good post, thanks for sharing....

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

useful post on construct.

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

you are really good at java programming

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

Informative content, thanks for sharing this post.

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

@ghasemkiani Helpful post. Good for beginners.

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

بسیار عالی
بهترین لحظات را براتون آرزو میکنم

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

Informative content, thanks for sharing this post.

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

Helpful post. thanks for the example.

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

educative

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

graet writing dear lovely friend @ghasemkiani. i all time like support and love your post and i well never forget you.

keep it up dear
@ghasemkiani

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

چه جالب
پس تعریف شی بصورت بالا انجام میشه در
reflect
ممنون

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

will be using Reflect a lot more, thanks for the post

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

thanks for the post, do you have any idea about browser compatibility?

@ylv19 | April 12, 2018, 3:04 p.m. | Votes: 0 | [ VOTE ]

Thanks, I am learning javascript in codecademy but I am beginner

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