IT. Expert System.

Java Script

indexOf()


Description

The indexOf() method is used to returns the first index at which a given element can be found in the array, or -1 if it is not found. The array is searched forwards (front to back).

This method has the form:

Array.indexOf(searchElement[, fromIndex])
Parameter Description
searchElement (required) Specifies the element to be located in the array
fromIndex (optional) Specifies the index at which to begin the search (default = 0)

If the fromIndex is greater than the length of the array, -1 is returned
If the fromIndex is less than zero, the search begins at the offset from the end of the array

Note: In all cases, the array is searched from front to back


Return Value

A Number that indicates the position of searchElement, or -1 if not found

Examples

The following example shows the basic use of this method.

<script>
var cols = [ "Cyan", "Magenta", "Yellow", "Black" ];
document.write(cols.indexOf("Magenta"));
</script>

This produces the following result:

Browser Support

Firefox IE Chrome Opera Safari

Version Information

This form was added in version: 1.6



Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 723 / . Delta: 0.00588 с