0
我在common.js文件中有以下方法。當我將「common.js」文件包含到打印文件中時,第一行出現編譯錯誤。Overloding Function.prototype時編譯錯誤
我應該如何解決這個問題?
Function.prototype.method = function (name, func) {
///<summary>
///Create a new method if it not ready exists
///</summary>
if (!this.prototype[name]) {
this.prototype[name] = func;
return this;
}
};
String.method('trim', function() {
return this.replace(/^\s|\s+$/g, '');
});