C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript TypedArray indexOf() MethodThe JavaScript indexof() Method is used to find the index of the element provided as the argument to the function.
Syntax:Array.indexof(value, start) Parameters:Value: Value to be search in the index. Start: Default 0. At which position to start the search. Return value:It returns the index of the search element. If the element cannot to be found in the array, this method returns -1. Browser Support:
Example 1JavaScript TypedArray indexOf() Method <script type="text/javascript"> // JavaScript to illustrate indexOf() method function JavaTpoint() { var array = [2,3,5,4,6,7,8,9,12]; document.write(array.indexOf(6, 5)); } JavaTpoint(); // expected output: arr[Output:-1] </script> Output: -1 Example 2JavaScript TypedArray indexOf() Method <script type="text/javascript"> // JavaScript to illustrate indexOf() method function JavaTpoint() { var array = [2,3,5,4,6,7,8,9,12]; document.write(array.indexOf(6, 2)); } JavaTpoint(); // expected output: arr[Output:4] </script> Output: 4
Next TopicJavaScript TypedArray Object
|