JS "portotype" (内置对象原型改写)

实现String对象的Trim功能:

<SCRIPT LANGUAGE="JavaScript">
<!--
//出处:网上搜集
// Trim() , Ltrim() , RTrim()

String.prototype.Trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.LTrim = function()
{
return this.replace(/(^\s*)/g, "");
}

String.prototype.RTrim = function()
{
return this.replace(/(\s*$)/g, "");
}

//-->
</SCRIPT>

 

 

JS内置对象:

String Math Date Number Boolean Array RegExp Function Object RegExp

 

posted @ 2009-01-15 14:17  T#S  阅读(355)  评论(0编辑  收藏  举报