JS 扩展方法prototype

时间:2023-03-10 00:07:11
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>