/*内置对象添加方法:String.prototype.trim(给String添加一个trim方法)
*^这个是以什么什么开头
*$这个是以什么什么结尾
*‘/s是String /d是数字’
*replace(/^\s+/ , "")把以字符开头的字符串替换为空字符串,
*replace(/\s+$/ , "")把以字符结尾的字符串替换为空字符串,
*/
String.prototype.trim = function()
{
return this.replace(/^\s+/ , "").replace(/\s+$/ , "");
}

posted on 2017-11-22 10:04  song.yan  阅读(607)  评论(0编辑  收藏  举报