0
こんにちは私は、firstFunctionからすべてのコンテンツをほとんど継承するsecondFunctionからDRYコード(繰り返しコードではない)を作成しようとしています。ほぼすべてを最初の関数から継承する
これは私が何をしたいの例だろうが、それはDRYではありません。
function firstFunction(){
\t
this.arrayObjectsToElastic = ["hello1", "hello2"]
this.anothervariable1= "anothervariable1"
this.anothervariable2= "anothervariable2"
this.targetVariableToRemove = "something"
return [this.arrayObjectsToElastic]
}
function secondFunction(){
\t
this.arrayObjectsToElastic = ["hello1", "hello2"]
this.anothervariable1= "anothervariable1"
this.anothervariable2= "anothervariable2"
return [this.arrayObjectsToElastic]
}
したがって、私はfirstFunctionからsecondFunction targetVariableToRemoveに「継承」したくありませんもしそうなら、私が走っている他のいくつかのプロセスでクラッシュすることになるからです。
を興味の絶対に何もしません、このサンプルでは、実際に具体的な方法でのお手伝いをするために少しあまりにも抽象的です。しかし、一般的には、関数本体のための「継承」はありません。 – deceze
@deceze私はそれをoopに変換しました、おそらくそれは助けます;) – Defoe