<script type="text/javascript">
Function.prototype.method = function(name,func){
this.prototype[name] = func;
return this;
}
String.method('deentityify',function(){
var entity={
quot:'"',
lt:'<',
gt:'>'
};
return function(){
return this.replace(/&([^&;]+);/g,
function(a,b){
var r = entity[b];
return typeof r==='string'?r:a;
}
);
};
}());
document.writeln('<">'.deentityify());//<">
</script>
js原型链继承和闭包例子
最新推荐文章于 2022-02-06 23:13:00 发布