// 返回字符的长度,一个中文算2个
String.prototype.ChineseLength=function()
{
return this.replace(/[^\x00-\xff]/g,"**").length;
}
// 判断字符串是否以指定的字符串结束
String.prototype.EndsWith = function(str)
{
return this.substr(this.length - str.length) == str;
}
// 去掉字符左端的的空白字符
String.prototype.LeftTrim = function()
{
return this.replace(/(^[\\s]*)/g, "");
}
// 去掉字符右端的空白字符
String.prototype.RightTrim = function()
{
return this.replace(/([\\s]*$)/g, "");
}
// 判断字符串是否以指定的字符串开始
String.prototype.StartsWith = function(str)
{
return this.substr(0, str.length) == str;
}
// 去掉字符两端的空白字符
String.prototype.Trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
// 为内部 String 对象添加方法
String.prototype.myMethod = function(){
return "my define method";
}
// 为内部 String 对象重载方法
String.prototype.toString = function(){
return "my define toString method";
}
var myObj = new String("foo");
alert(myObj.myMethod());
alert(myObj);
alert("foo".toString());
function Employee() {
this.dept = "HR";
this.manager = "John Johnson";
}
String.prototype = new Employee;
var myString = new String("foo");
object1.prototype.isPrototypeOf(0bject2);
function Person() {
this.name = "Rob Roberson";
this.age = 31;
}
function Employee() {
this.dept = "HR";
this.manager = "John Johnson";
}
Employee.prototype = new Person();
var Ken = new Employee();
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有