日期:2014-05-16  浏览次数:20501 次

javascript修改对象!!

function StringBuffer(){
??? this.__string__=new Array();
??? }
StringBuffer.prototype.append=function(str){
??? this.__string__.push(str);
??? }???
StringBuffer.prototype.join=function(){
??? return this.__string__.join("");
??? }???
var str1=new StringBuffer();
str1.append("4");
str1.append("2");

alert(parseInt(str1.join()).toString(16));

?

//给ES中的每个本地对象添加新方法
Object.prototype.ShowValue=function(){
??? return this.valueOf();
??? }
??? var s=111;
alert(s.ShowValue());???