JS Built-ins
RegExpflagsbeginner

RegExp flags β€” typeof

πŸ“– Usage Example
const re = /hello/gi
console.log(re.flags) // β†’ 'gi'

Read RegExp.flags to get a string of all active flags on the regular expression.

RegExp.prototype.flags

The flags property always returns a string.

Challenge: Verify that typeof /test/g.flags is 'string'.

πŸ’‘ Hints (1)
  • β€’ flags always returns a string, even if empty