我们都知道 "STRING".toLowerCase() 这样一句代码就能直接返回 "string",
那能不能自定义一个类似 toLowerCase() 的函数,
例如 "STRING".aaa() 这样就能直接返回 "STRING" 经过 aaa() 处理过的字符串?
不知道我的描述够不够清楚!!!
如果是转小写干嘛要自定义一个函数,如果你要另外处理过字符串,可以扩展String类型的prototype添加自定义函数
String.prototype.aaa=function(){return this.toLowerCase()/*或者自己的逻辑*/}
alert('AAA'.aaa())
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,'')};
alert(' AAA '.trim().length)
可以啊,在里面调用toLowercase就行了