JS 扩展方法prototype

通过类对象的prototype设置扩展方法,下面为String对象增加quote(两边加字符)方法
 

<script type="text/javascript">

        String.prototype.isEmail= function(){
            return this.indexOf('@')!=-1?true:false;
        }


        alert('dxm@163.com'.isEmail());
    </script>
原文地址:https://www.cnblogs.com/dxmfans/p/9434874.html