English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The JS Array type itself does not have a method to check if it contains a string, the following code implements this function, those who need it can take a look:
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; };
That's all for the simple method of adding a string to an array in JS brought to you by the editor. Hope everyone will support and cheer for the tutorial~