It's explained in the GDScript basics doc:
self
- Refers to current class instance.
It serves essentially the same purpose as self
or this
in other object-oriented languages.
Specifically in GDScript, when used in a script, it's a reference to the object the script is attached to.
It's used whenever you need a reference to the current node, for example when connecting a signal to a local function:
func _ready():
connect("some_signal", self, "some_function")
func some_function():
# signal is now connected here