What does search() do exactly?

I looked it up on w3schools but i couldnt understand it at all.

Do you mean String.search() or "A String".search() ?

In the future it is best to refer to methods by their prototype, and you should avoid w3schools as a reference. Mozillal has a full reference available for reference.

The search() method executes a search for a match between a regular expression and this String object.

The index of the first match between the regular expression and the given string; if not found, -1.