Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extensions of Javascript function shorthand

I know it's possible to define a function this way:

x=y=>y*y

which corresponds to:

function x(y){ return y*y; }

But I was wondering, is it possible to extend this to two or more arguments?

i.e. x=y,z=>y+z or similar to correspond to function x(y,z){ return y*z; }

Is there a similar convention to the very first example that allows for two or more arguments? I know that the x=y,z=>y+z syntax isn't right as I get errors regarding the definitions of at least one of variables... So how can it be done, or rather... can it be done??

like image 709
Eliseo D'Annunzio Avatar asked Dec 01 '25 03:12

Eliseo D'Annunzio


1 Answers

yes try

x=(z,y)=>z*y 

haha :D http://jsfiddle.net/FaSv2/

like image 68
clancer Avatar answered Dec 02 '25 18:12

clancer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!