Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript: is the arguments array deprecated?

Most sites say "callee" as a property of Function.arguments is deprecated. But some sites go further and say the whole of Functions.argument is deprecated E.g. http://aptana.com/reference/api/Arguments.html Why only mention callee if the whole routine is dead in the water? I only just discovered "arguments" and it seems incredibly useful E.g: http://hungred.com/how-to/secret-arguments-array-javascript/

like image 963
Chris Tolworthy Avatar asked Nov 14 '11 11:11

Chris Tolworthy


People also ask

Are arguments deprecated?

Note: The arguments property of Function objects is deprecated. The recommended way to access the arguments object is to refer to the variable arguments available within functions.

Is arguments an array in JavaScript?

arguments is an array-like object, which means that arguments has a length property and properties indexed from zero, but it doesn't have Array 's built-in methods like forEach() or map() . However, it can be converted to a real Array , using one of slice() , Array. from() , or spread syntax.

Can an array be an argument in a function JavaScript?

Method 1: Using the apply() method: The apply() method is used to call a function with the given arguments as an array or array-like object. It contains two parameters. The this value provides a call to the function and the arguments array contains the array of arguments to be passed.

What is deprecated in JavaScript?

A deprecated method or function is one that has been outdated. Deprecated methods or functions may become obsolete in the future, but browsers should continue to support deprecated methods for backward compatibility.


2 Answers

Function.arguments is deprecated, but it's only deprecated in favor of the vanilla arguments object that's available within a function. (e.g. using x = arguments[i]; instead of x = theFunc.arguments[i];)

That's now the preferred (and as you say, extremely useful) method for accessing the ordinal arguments received.

like image 184
Alex K. Avatar answered Sep 23 '22 16:09

Alex K.


Afaik arguments is deprecated as a property of Function. See this MDN-link, or this one

like image 40
KooiInc Avatar answered Sep 24 '22 16:09

KooiInc