チェーンを介して関数に配列を渡すことはできますか?私はこれが可能であると提案した仕事のためにJavaScriptテストに出くわしました。それは...ですか?JavaScriptのチェーン継承を介して関数に値を送信
var hereIsArray = [13,27,49,57];
function printArray() {
// insert code here to print array...
// this may read the parent of the chain, or the variable placed before the function in the chain.
};
hereIsArray.printArray();
私は括弧の間には、関数に変数を渡すことに精通していると私はそれを行うだろう方法でしょう。
以下は、テスト(質問#5)が求めているもののコピーです。 "assignment.log"は出力をチェックするために作成した関数です。彼らが偵察している答えを見ることができます。
//#5 write code so that console logs print out true
// add(addValue) should return a new arrays where addValue
// is added to each value of original array
// i.e. [6, 7, 8, 9, 10] and [11, 12, 13, 14, 15]
// [your code goes here]
var e = [1, 2, 3, 4, 5];
assignment.log(e.add(5) == '[6,7,8,9,10]', 5);
var d = [1, 2, 3, 4, 5];
assignment.log(d.add(10) == '[11,12,13,14,15]', 5);
はい、それはプロトタイプ連鎖と呼ばれています –
ええ、あなたは 'prototype'を使うことができますが、JavaScriptは配列を' .toString() 'で文字列に変換することができます。 – PHPglue
JavaScriptを使用して数学を行う場合は、各数字にMath.pow(10,17)を乗算し、小数点以下を扱うときに加算または減算を行う場合は、同じ数値で除算する前に加算または減算します。 – PHPglue