首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

js原形链继承和闭包例子

2012-11-25 
js原型链继承和闭包例子script typetext/javascriptFunction.prototype.method function(name,func

js原型链继承和闭包例子

 <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('&lt;&quot;&gt;'.deentityify());//<"></script>

热点排行