How can I get all the function arguments in javascript inside an array?
function(a, b, c){
// here how can I get an array of all the arguments passed to this function
// like [value of a, value of b, value of c]
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You use the
argumentsobject (it’s not an array as stated in other answers, it has some other interesting properties, seehere).
It is automatically created in the function’s scope when you define the function itself.
There is another form as a property of the function object:
but, though supported, it has become deprecated.