Function方法: extend
用一个新的方法戒属性扩展Function对象。
语法:
myFunction.extend(key, value);
// 或者
myFunction.extend(object);
参数:
- key - (string) 方法戒属性的键。
- value - (mixed) 方法戒属性的值。 或者
- object - (object) 一个要扩展到方法的方法戒属性的键值对对象。
返回值:
- (function) Function对象。
举例:
var fn = function(){};
fn.extend('m',function(text){alert(text)});
fn.m('hello');
var myFunction = function(){};
myFunction.extend('alert', function(text){ alert(text); });
myFunction.alert('Hello!'); // alerts Hello!
// 使用对象
myFunction.extend({ alert: function(text){ alert(text); } });