5
Javascript:The Definitive Guide(2011)はstrictモードでは動作しませんが、strictモードで実装する方法を示していないこの例(p.186)があります。ベストプラクティス/セキュリティ/パフォーマンス - 厳格なモードでこのようなことをする最良の方法は何ですか?コードは次のとおりです。厳密モード:argument.callee.lengthの代わりに?
// This function uses arguments.callee, so it won't work in strict mode.
function check(args) {
var actual = args.length; // The actual number of arguments
var expected = args.callee.length; // The expected number of arguments
if (actual !== expected) // Throw an exception if they differ.
throw Error("Expected " + expected + "args; got " + actual);
}
function f(x, y, z) {
check(arguments); // Check that the actual # of args matches expected #.
return x + y + z; // Now do the rest of the function normally.
}
なぜコミュニティのwikiのすべて – Raynos
@Raynos:私は推測SO担当者ポイントについてだけ心配していません。貢献したいと思っている他の人たちにも答えを呼びかけます。 –