1
javascriptでは、以下のような異なる方法で同じ関数を書くことができます。これはテストに簡単にどちらの方法であるJavaスクリプトでユニットテスト関数を書くためのより良い方法は何ですか?
// 1st way ============
var app = {};
app.name = "abc"
app.init = function() {
return "test";
};
// 2nd way ============
function app() {
this.name = "abc";
};
app.prototype.init = function() {
return "test";
};