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.

asked Sep 21, 2016 at 16:41
2
  • I'm not seeing a particular name in the spec but they are contextual values. the closest I see in the spec names this as the Value of the call while arguments is the ArgumentList Commented Sep 21, 2016 at 17:19
  • ecma-international.org/ecma-262/7.0/… Commented Sep 21, 2016 at 17:19

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.

answered Sep 21, 2016 at 18:23
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.

answered Sep 21, 2016 at 17:52
-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

answered Sep 21, 2016 at 17:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.