下面小編就為大家帶來一篇JS給Array添加是否包含字符串的簡單方法。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
JS的Array類型,本身并沒有是否包含某個字符串的方法,下面的代碼實現了此功能,有需要的同學可以看一下:文章源自四五設計網-http://www.wasochina.com/38926.html
Array.prototype.contains = function(v){ var b = false; for(var i=0;i<this.length;i++){ if(this[i] == v){ b = true; break; } } return b; };
以上就是小編為大家帶來的JS給Array添加是否包含字符串的簡單方法全部內容了。文章源自四五設計網-http://www.wasochina.com/38926.html 文章源自四五設計網-http://www.wasochina.com/38926.html
我的微信
微信掃一掃

我的微信
惠生活福利社
微信掃一掃

我的公眾號
評論