ects/Object/constructor)
    2. [ ` Object.prototype.__proto__ ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) Deprecated 
  13. Methods 
    1. [ ` Object.prototype.__defineGetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__) Deprecated 
    2. [ ` Object.prototype.__defineSetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__) Deprecated 
    3. [ ` Object.prototype.__lookupGetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__) Deprecated 
    4. [ ` Object.prototype.__lookupSetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupSetter__) Deprecated 
    5. [ ` Object.prototype.hasOwnProperty() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)
    6. [ ` Object.prototype.isPrototypeOf() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf)
    7. [ ` Object.prototype.propertyIsEnumerable() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable)
    8. [ ` Object.prototype.toLocaleString() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString)
    9. [ ` Object.prototype.toString() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
    10. [ ` Object.prototype.valueOf() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf)

##  In this article

  * Try it 
  * Description 
  * Examples 
  * Specifications 
  * Browser compatibility 
  * See also 

#  RegExp.prototype.global

The **` global ` ** accessor property of [ ` RegExp ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) instances returns
whether or not the ` g ` flag is used with this regular expression.

##  Try it

##  Description

` RegExp.prototype.global ` has the value ` true ` if the ` g ` flag was used;
otherwise, ` false ` . The ` g ` flag indicates that the regular expression
should be tested against all possible matches in a string. Each call to [ `
exec() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
will update its [ ` lastIndex ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex) property, so
that the next call to ` exec() ` will start at the next character.

Some methods, such as [ ` String.prototype.matchAll() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll) and [ `
String.prototype.replaceAll() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll) , will
validate that, if the parameter is a regex, it is global. The regex's [ `
@@match ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match) and [ `
@@replace ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@replace) methods
(called by [ ` String.prototype.match() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/String/match) and [ `
String.prototype.replace() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) ) would also
have different behaviors when the regex is global.

The set accessor of ` global ` is ` undefined ` . You cannot change this
property directly.

##  Examples

###  Using global

js

    
    
    const regex = /foo/g;
    console.log(regex.global); // true
    
    const str = "fooexamplefoo";
    const str1 = str.replace(regex, "");
    console.log(str1); // example
    
    const regex1 = /foo/;
    const str2 = str.replace(regex1, "");
    console.log(str2); // examplefoo
    

##  Specifications

Specification  
---  
[ ECMAScript Language Specification  
#  sec-get-regexp.prototype.global  ](https://tc39.es/ecma262/multipage/text-
processing.html#sec-get-regexp.prototype.global)  
  
##  Browser compatibility

BCD tables only load in the browser  with JavaScript enabled. Enable
JavaScript to view data.

##  See also

  * [ ` RegExp.prototype.lastIndex ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/l