判断数组是否包含某个元素

来源:互联网 发布:mt4行情软件 编辑:程序博客网 时间:2024/05/22 04:25
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title></head><body><script>    Array.prototype.S = String.fromCharCode(2);    Array.prototype.in_array = function (e) {        var r = new RegExp(this.S + e + this.S);        return (r.test(this.S + this.join(this.S) + this.S));    };    var arr = ["a", "bcc"];    alert(arr.in_array("c"))</script></body></html>
原创粉丝点击