Open Playground
JS FunctionsLesson #225

JavaScript Function Reference

In JavaScript, the this keyword refers to an object.

Function Object Methods & Properties

Revised December 2025

NameDescription
apply()Calls a function with a specified this value and an array of arguments
bind()Returns a function with a specified this value
call()Calls a function with a specified this value and individual arguments
lengthReturns the number of (expected) parameters of a function
nameReturns the name of the function
toString()Returns a string representation of the function's source.

What is this?

In JavaScript, the this keyword refers to an object.

The this keyword refers to different objects depending on how it is used:

Alone, this refers to the global object.
In a function, this refers to the global object.
In a function, in strict mode, this is undefined.
In an object method, this refers to the object.
In an event, this refers to the element that received the event.
In methods like call(), apply() and bind(), this can refer to any object.
this is not a variable. > this is a keyword. > You cannot change the value of this.

This Precedence

Use the following precedence of order to determine which object this refers to:

OrderObjectBecause
1bind()this is in a function being called using bind()
2apply()this is in a function being called using apply()
2call()this is in a function being called using call()
3Object methodthis is in an object function (method)
4Global scopethis is in a function in the global scope

Share

this Precedence

Use the following precedence of order to determine which object this refers to:

OrderObjectBecause
1bind()this is in a function being called using bind()
2apply()this is in a function being called using apply()
2call()this in is a function being called using call()
3Object methodthis in is an object function (method)
4Global scopethis in isa function in the global scope