rence/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 
  * Description 
  * Examples 
  * Specifications 
  * Browser compatibility 
  * See also 

#  RegExp.prototype.hasIndices

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

##  Try it

##  Description

` RegExp.prototype.hasIndices ` has the value ` true ` if the ` d ` flag was
used; otherwise, ` false ` . The ` d ` flag indicates that the result of a
regular expression match should contain the start and end indices of the
substrings of each capture group. It does not change the regex's
interpretation or matching behavior in any way, but only provides additional
information in the matching result.

This flag primarily affects the return value of [ ` exec() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) . If the ` d `
flag is present, the array returned by ` exec() ` has an additional ` indices
` property as described in the ` exec() ` method's [ return value ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec#return_value) .
Because all other regex-related methods (such as [ ` String.prototype.match()
` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) ) call `
exec() ` internally, they will also return the indices if the regex has the `
d ` flag.

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

##  Examples

There's a more detailed usage example at [ Groups and backreferences > Using
groups and match indices ](/en-
US/docs/Web/JavaScript/Guide/Regular_expressions/Groups_and_backreferences#using_groups_and_match_indices)
.

###  Using hasIndices

js

    
    
    const str1 = "foo bar foo";
    
    const regex1 = /foo/dg;
    
    console.log(regex1.hasIndices); // true
    
    console.log(regex1.exec(str1).indices[0]); // [0, 3]
    console.log(regex1.exec(str1).indices[0]); // [8, 11]
    
    const str2 = "foo bar foo";
    
    const regex2 = /foo/;
    
    console.log(regex2.hasIndices); // false
    
    console.log(regex2.exec(str2).indices); // undefined
    

##  Specifications

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

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