读书人

javascript批改对象!

发布时间: 2012-11-22 00:16:41 作者: rapoo

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());???

读书人网 >JavaScript

热点推荐