Standard built-ins
Symbol.replace
Key for the replacement hook consulted by string replace and replaceAll; receives the string and replacement.
Formal Syntax & Structure
javascript syntaxjavascript
Symbol.replaceReturn Value
symbol
The predefined protocol key.
Working Example
Example Snippetjavascript
const x={[Symbol.replace](s,r){return r+s;}};console.log("ab".replace(x,"!"));