As per the ECMAScript, the flags in RegExp should simply be strings. The fact that the code still works is because RegExp applies toString on the flags. When there is only one element in the array, it works fine, but if there is another flag, e.g ["g", "i"], it will result in "g,i", which throws a SyntaxError.
As per the ECMAScript, the flags in RegExp should simply be strings. The fact that the code still works is because RegExp applies toString on the flags. When there is only one element in the array, it works fine, but if there is another flag, e.g ["g", "i"], it will result in "g,i", which throws a SyntaxError.