For instance, a variable named arrayElements of array type contains [1,2,3,4].
How do i get the position of which that has the value “3” in the array variable besides using loop?
thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
consider using
indexOf, it returns the 0-based position of the element in the array.e.g.
Note that this method is not available in IE 8 and below.