The well-known symbol specifies the method that returns the index within a string that matches the regular expression. This function is called by the method.

For more information, see RegExp.prototype[@@search]() and

Property attributes of
Writable no
Enumerable no
Configurable no


class caseInsensitiveSearch {
  constructor(value) {
    this.value = value.toLowerCase();
  [](string) {
    return string.toLowerCase().indexOf(this.value);

console.log('foobar'.search(new caseInsensitiveSearch('BaR')));
// expected output: 3


ECMAScript (ECMA-262)
The definition of '' in that specification.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
searchChrome Full support 50Edge Full support 79Firefox Full support 49IE No support NoOpera Full support 37Safari Full support 10WebView Android Full support 50Chrome Android Full support 50Firefox Android Full support 49Opera Android Full support 37Safari iOS Full support 10Samsung Internet Android Full support 5.0nodejs Full support 6.0.0


Full support  
Full support
No support  
No support

See also