This is one of the additions to the String object to support regular expressions.
The matches are returned in an array with each match in a separate element. You can use this to strip numeric values out of a string containing words and numbers by looking for a pattern such as:
This would yield all the numeric values from a string.
The g attribute affects whether a single item matches or whether all of them match.
When the g attribute is not used, the array object has an additional property named index, which contains the character location where the match occurred. It also has an additional property called input, which contains the original string that was searched for a match.