优化JS代码体积
原代码如图:
通过闭包的curry技术,优化后:
function RegGenerator(reg){ return function(){ return this?reg.test(this):false; }}String.prototype.is_qq=RegGenerator(/^\d{5,15}$/ );"123".is_qq(); //false"123456".is_qq(); //true