Prototype Properties

A regex exposes read-only accessors: source (the pattern text), flags (in the canonical order dgimsuvy) and the per-flag booleans of Flags. Only lastIndex is writable: g and y regexes keep there the position where the next exec() or test() starts. String.raw spares you doubled backslashes in pattern strings.

Reading a regex's properties and the lastIndex trapJavaScriptLive
const r = new RegExp(String.raw`\d+`, 'dg');
console.log(r.source, r.flags, r.global, r.hasIndices, r.unicodeSets);
console.log(r.test('a1'), r.lastIndex, r.test('a1'), r.lastIndex);  // g makes test() stateful