Check if an array item is set in JS

前端 未结 9 1112
别跟我提以往
别跟我提以往 2021-02-02 08:10

I\'ve got an array

    var assoc_pagine = new Array();
    assoc_pagine[\"home\"]=0;
    assoc_pagine[\"about\"]=1;
    assoc_pagine[\"work\"]=2;
9条回答
  •  执念已碎
    2021-02-02 08:49

    function isset(key){
    ret = false;
    array_example.forEach(function(entry) {
      if( entry == key ){
        ret = true;
      }
    });
    return ret;
    }
    
    alert( isset("key_search") );
    

提交回复
热议问题