在js中,Function构造函数的实例化对象为Function,Array,Object构造函数。
<script>
Function.prototype.addMethod = function (name,fn) {
this.prototype[name]=fn;
}
Array.addMethod('test',function(){
console.log('Array method add');
});
Object.addMethod('test',function(){
console.log('Object method add');
});
Function.addMethod('test',function(){
console.log('Function method add');
});
var a=[],
b={},
c=function(){};
a.test();
b.test();
c.test();
</script>