+ 5

how to access argument/parameters?

If I pass more arguments than are defined, how to access those arguments? your answer is easy. use arguments [index_number] ; yeah you are right. there is my question. if I named a parameter "arguments" then how to access those arguments which is not defined. for example: function f(x, y){ return x+y+arguments; } f("HELLO ", " SHAKIB ", " HASSAN "); this f unction can access arguments which is not defined. function g(x, arguments) { return x+arguments+arguments [1]; } g("HELLO ", " SHAKIB ", " HASSAN"); this g function is not working like f function. so in this case how to access the arguments which is not defined? with out using rest operator.

20th Sep 2021, 7:17 PM
KAZI MD SHAKIB HASSAN
KAZI MD SHAKIB HASSAN - avatar
6 Respostas
+ 4
is there another way? with out using rest operator. Abhay
20th Sep 2021, 8:05 PM
KAZI MD SHAKIB HASSAN
KAZI MD SHAKIB HASSAN - avatar
+ 2
Thanks Abhay Lisa. I am learning deeply. that's why so many odd questions is running on my mind. 🤔🤔!!
21st Sep 2021, 5:05 AM
KAZI MD SHAKIB HASSAN
KAZI MD SHAKIB HASSAN - avatar
+ 1
Using rest operator ! function g(x,...arguments) { return x+arguments[0]+arguments [1]; }
20th Sep 2021, 7:38 PM
Abhay
Abhay - avatar
+ 1
KAZI MD SHAKIB HASSAN sorry but i don't know. Why would you want to do it anyway ? It's like asking if i override the behaviour for console.log , then how can i access the original console.log functionality ? I mean you just need to know the syntax of language and so you will never try to include arguments as a argument.
20th Sep 2021, 8:42 PM
Abhay
Abhay - avatar
+ 1
In the function, all arguments are kept in an *object*: In my example I cast the arguments objects values to an array and output the array. https://code.sololearn.com/Wj5J364yLluH/?ref=app
20th Sep 2021, 9:55 PM
Lisa
Lisa - avatar
0
Je pense que JavaScript a fonction et multi paramètres peut mieux faire l'affaire.
27th Sep 2021, 6:19 PM
Emmanuel Simplice AGBA
Emmanuel Simplice AGBA - avatar