Array does not have the indexOf method, which makes it troublesome to search for the index of an element in an Array. Therefore, Array is extended through prototype. prototype. indexOf (), but there is a problem when traversing the Array. The Array
Use of the indexOf method String type in the JavaScript Array
Let's take a look at the well-known string usage.
let str = 'orange'; str.indexOf('o'); //0 str.indexOf('n'); //3 str.indexOf('c'); //-1
Here 0 and 3 are the positions where o and n
Array does not have the indexOf method. In this way, it is troublesome to search for the index of an element in an Array. For the convenience of calling, Array is extended through prototype. prototype. indexOf (), which makes it easier to use.
This article mainly introduces the extension of Array for JS. prototype. the problem caused by indexOf and the solution can be found by a friend who needs it. the Array does not have the indexOf method, so it is troublesome to search for the index
The array methods in the ECMA Script5 such as indexof (), ForEach (), map (), filter (), some () do not support ie6~8, but there is still a large majority of users in the country using Ie6~8, and the above array method is really useful. In the past,
Array does not have the indexOf method. In this way, it is troublesome to search for the index of an element in an Array. For the convenience of calling, Array is extended through prototype. prototype. indexOf (), which makes it easier to use.
This article mainly introduces the extension of Array for JS. prototype. the problem caused by indexOf and the solution can be found by a friend who needs it. The Array does not have the indexOf method, so it is troublesome to search for the index
Problems caused by extension of Array. prototype. indexOf for JS and solutions, jsarrayindexof
Array does not have the indexOf method. In this way, it is troublesome to search for the index of an element in an Array. For the convenience of calling,
Objective
Believe that when it comes to indexOf everyone is not unfamiliar, to determine whether the string contains substrings are particularly common, is not skilled students of the sharp weapon. This article on the recent encounter of a problem,
Array does not have the indexof method. In this way, it is troublesome to search for the index of an element in an array. For the convenience of calling, array is extended through prototype. prototype. indexof (), which makes it easier to use.
Array.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.