The argument to .match()
is treated as a regular expression. Parentheses are meta-characters that mean something in that context. Specifically, they group portions of the matched string. Thus, your regular expression (test)
matched the substring "test". The return value gives you the entire match as the first element of the array, and the first group as the second. In this case, because your group covered the whole matched substring, they're the same.
This is the sort of thing that the MDN documentation can quickly clear up:
Parameters
regexp
A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj).