0

I understand in JavaScript the this and arguments "variables" are automatically made available inside functions. Is there a formal name for these kinds of variables that are automatically made available and don't need to be sent as parameters?

Is "variables" even the correct term for them? Since this and arguments can be overwritten to any value, "variables" seems to fit. But is there any term that is more specific and captures the automatic, non-parameter nature of them?

A related variable is the event object sent automatically as the first parameter to any function that is bound as an event handler (at least in the W3C model). Is there a technical term for this kind of variable that is also sent automatically, but (unlike this and arguments) is only accessible if included in the function's parameter list?

I'm looking for a noun: "this and arguments are both __________."

Or perhaps an adjective: "this and arguments are ______________ variables."

The term need not be specific to JavaScript. It may be a general programming term (such as lambda expression) that has been incorporated into the JavaScript language.

2

3 Answers 3

2

They're not the same thing.

this is a keyword. (MDN) And conversationally, I would probably describe it as a keyword referring to the "current object" or "the object you're operating within".

arguments is "a local variable available within all functions." (MDN) Conversationally, I would personally describe it as a magic variable.

2

One possible name might be "implicit parameter".

It is important to note though that the two parameters are treated differently. We dynamically dispatch on the this parameter, while the arguments parameter is treated like any other.

-2

a Call in javascript has 3 parameters. Function Object, This Argument and Arguments List.

http://www.ecma-international.org/ecma-262/7.0/index.html#sec-call

Not the answer you're looking for? Browse other questions tagged or ask your own question.