As you might know already, there are functions and there are methods. Methods are functions which are declared on an object. To call the method, you access the object.
For example
The fun part is, strings and regex and generally most other stuff in JS have their methods. You alreayd know arrays and the planty of methods they got. Any array you define have access to those methods, all you need to do is call it on the array itself. For example [1, 3, 2].sort(). An example of a regex method is test. You just call it on any regex. test takes a string as a parameter, which is used to be tested against the regex. /regex/.test("string"). A confusen can arrise with match, which is a string method, i.e. you call it on a string. It also takes a regex as an argument. So it looks like this - "string".match(/regex/). Lot of people(me included) get confused in the start, why the string/regex places are reversed, or why match and test work in opposite ways. It is because one is method defined on the String object, while the other is a method belonging to the RegExp one. They also happen to take as argument the opposite, which makes for a confusing banther. And just like match, there are other string methods, like replace, slice, toUpperCase, which also happen to take quite different arguments(or none), and slice is also a method on the Array object(another fact that can confuse newbie).