//destination 子对象
//source 父对象
Object.extend = function(destination,source){
for(property in source){
destination[property] = source[property];
}
return destination;
}
Object.extend(String.prototype,{
stripTags:function(){
return this.replace(/<//?[^>]+>/gi,'');
},
toArray:function(){
return this.split('');
},
comelize:function(){
var oStringList = this.split('-');
//处理-
if(oStringList.length == 1){
return oStringList[0];
}
//主要处理background-这样的字符串的
var camelilzedString = this.indexOf('-') == 0?
oStringList[0].charAt(0).toUpperCase()+oStringList[0].substring(1):
oStringList[0];
for(var i=1; i<oStringList.length; i++){
var s = oStringList[i];
camelilzedString += s.charAt(0).toUpperCase()+s.substring(1);
}
return camelilzedString;
}
});
alert("<b><i>Hello</i>,world!".stripTags());
alert("abcdefg".toArray()[3]=='d');
alert("background-color".comelize());