C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Symbol.search PropertyThe JavaScript Symbol.search symbol determine the method that returns the index within a string that matches with the regular expression. Syntax[Symbol.search](string) ParametersString. Return valueThe position of a string. Browser Support
Example 1<script> //JavaScript to illustrate Symbol.search class S { constructor(value) { this.value = value; } [Symbol.search](string) { return string.indexOf(this.value); } } document.write('JavaTpoint'.search(new S('int'))); //expected output: 7 </script> Output: 7 Example 2<script> //JavaScript to illustrate Symbol.search class S { constructor(value) { this.value = value; } [Symbol.search](string) { return string.indexOf(this.value); } } document.write('Symbol'.search(new S('ol'))); //expected output:4 </script> Output: 4
Next TopicJavaScript Symbol
|