Home >Web Front-end >JS Tutorial >Angularjs array determines the instance code of an element

Angularjs array determines the instance code of an element

小云云
小云云Original
2018-03-01 09:51:461492browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn