有没有判断字符串有没有相等的函数。像是oracle 中的in这个方法似的SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1,value2,...)不想写成下面这种方式。在javascript中有这种方法吗?
 if( (getUserId() == 'm0810576') || (getUserId() == 'm1110243') || (getUserId() == '08105767') )
      {
      }
      else{

解决方案 »

  1.   

    http://blog.csdn.net/lixianlin/article/details/2334076
      

  2.   

    Array.prototype.contains = function(obj) { 
        var i = this.length; 
        while (i--) { 
            if (this[i] === obj) { 
                return true; 
            } 
        } 
        return false; 
    }  And now you can simply use the following:
    alert([1, 2, 3].contains(2)); // => true 
    alert([1, 2, 3].contains('2')); // => false 
      

  3.   

    javascript里面你就只能那样用吧