Home >Web Front-end >JS Tutorial >How to determine whether an element is contained in an angularjs array
Below I will share with you an example of determining whether an angularjs array contains a certain element. It has a good reference value and I hope it will be helpful to everyone.
This 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; }
How to use:
tmp.in_array(id)
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
How to use js to determine that the input box cannot be a space or a null value?
How to use vue to determine if the input content is all spaces?
How to return to the top through the tween method in the vue project
The above is the detailed content of How to determine whether an element is contained in an angularjs array. For more information, please follow other related articles on the PHP Chinese website!