たとえば、次の「StartsWith」拡張子を見てください。
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str) {
return this.slice(0, str.length) == str;
};
}
もし私が Web アプリを書いていたらExtensionMethods.js
、サイト内の Web ページにインポートしたページにそのコードを貼り付けます。
しかし、Node.jsを使用するサーバーでこれを使用する場合はどうでしょうか。
ありがとう!