Home

ThisArg

ThisArg is a conventional name for a value that should be used as the this context when a function is invoked. It is not a language keyword, but a common parameter name used by JavaScript standard library methods that accept callbacks, such as array iteration or searching methods, as well as by the Function.prototype methods call, apply, and bind.

In many methods that take a callback, the second argument is thisArg. When the callback is invoked

Function.prototype.call and Function.prototype.apply explicitly set a function’s this value by passing thisArg as the first argument.

If no thisArg is provided, the this inside a regular function call depends on strict mode: undefined

This concept helps manage context and scope in JavaScript functional patterns. See also Function.prototype.call, Function.prototype.apply, Function.prototype.bind,

by
the
method,
thisArg
is
used
as
the
this
value
inside
the
callback.
Arrow
functions,
which
close
over
their
surrounding
this,
ignore
thisArg.
Function.prototype.bind
returns
a
new
function
that,
when
called,
uses
thisArg
as
its
this
value.
In
both
cases,
if
thisArg
is
a
primitive
value,
it
is
boxed
into
an
object;
if
it
is
null
or
undefined,
the
behavior
depends
on
strict
mode.
in
strict
mode,
or
the
global
object
in
non-strict
mode.
In
module
code
or
many
environments,
the
default
can
be
undefined.
and
array
methods
that
accept
a
callback
with
an
optional
thisArg.