Standard built-ins

Symbol.search

Try the free JavaScript compiler

Key consulted by string search for a custom matching operation. Conventional search returns the first matching offset or -1.

Formal Syntax & Structure

javascript syntaxjavascript
Symbol.search

Return Value

symbol

The predefined protocol key.

Working Example

Example Snippetjavascript
const x={[Symbol.search](s){return s.indexOf("b");}};console.log("abc".search(x));
JavaScript Reference