ocs/Web/JavaScript/Reference/Global_Objects/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 
  * Syntax 
  * Description 
  * Examples 
  * Specifications 
  * Browser compatibility 
  * See also 

#  RegExp.prototype[@@matchAll]()

The **` [@@matchAll]() ` ** method of [ ` RegExp ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) instances specifies
how [ ` String.prototype.matchAll ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll) should
behave.

##  Try it

##  Syntax

js

    
    
    regexp[Symbol.matchAll](str)
    

###  Parameters

` str `

    

A [ ` String ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
that is a target of the match.

###  Return value

An [ iterable iterator object ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Iterator) (which is not
restartable) of matches. Each match is an array with the same shape as the
return value of [ ` RegExp.prototype.exec() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) .

##  Description

This method is called internally in [ ` String.prototype.matchAll() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll) . For
example, the following two examples return the same result.

js

    
    
    "abc".matchAll(/a/g);
    
    /a/g[Symbol.matchAll]("abc");
    

Like [ ` @@split ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@split) , ` @@matchAll
` starts by using [ ` @@species ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@species) to construct
a new regex, thus avoiding mutating the original regexp in any way. [ `
lastIndex ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex) starts as
the original regex's value.

js

    
    
    const regexp = /[a-c]/g;
    regexp.lastIndex = 1;
    const str = "abc";
    Array.from(str.matchAll(regexp), (m) => `${regexp.lastIndex} ${m[0]}`);
    // [ "1 b", "1 c" ]
    

The validation that the input is a global regex happens in [ `
String.prototype.matchAll() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll) . `
@@matchAll ` does not validate the input. If the regex is not global, the
returned iterator yields the [ ` exec() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) result once and
then returns ` undefined ` . If the regexp is global, each time the returned
iterator's ` next() ` method is called, the regex's [ ` exec() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) is called and the
result is yield