Home >Web Front-end >JS Tutorial >Angularjs array determines the instance code of an element
This article mainly shares with you an example of how to determine whether an angularjs array contains an element, that is, the in_array function, which determines whether an array contains an element.
Array.prototype.in_array = function(e) { for(i=0;i<this.length;i++) { if(this[i] == e) return true; } return false; }
Usage:
tmp.in_array(id)
Related recommendations:
php determines whether the element appears in the array
jQuery Method to determine whether an element is hidden
JS implementation code to determine whether an element is in an array_javascript skills
The above is the detailed content of Angularjs array determines the instance code of an element. For more information, please follow other related articles on the PHP Chinese website!