JS Built-ins
RegExpglobalbeginner

RegExp global β€” result is boolean

πŸ“– Usage Example
const re = /a/g
console.log(re.global) // β†’ true
const re2 = /a/
console.log(re2.global) // β†’ false

Read RegExp.global to check whether the 'g' flag is set on the regular expression.

RegExp.prototype.global

The global property always returns a boolean value.

Challenge: Confirm that /pattern/g.global is strictly equal to true.

πŸ’‘ Hints (1)
  • β€’ global returns a strict boolean, not a truthy/falsy value