Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Ask QT how to judge whether there is an element I want in the array?
Ask QT how to judge whether there is an element I want in the array?
You can use the indexOf () method of an array. If the return value is-1, it means it does not exist; if the return value is an integer greater than-1, it means it exists. For example:

var arr =;

arr . index of( 1); //Returns 0

arr . index of(5); //Return - 1

Attachment: The return value is the position of the foremost element in the array.