ここJavaScriptCoreにおける(ニトロ)からFunction.prototype.apply
のソースコードは、あなたがしたい場合は、その実装を見つけるために、V8とJaegerMonkeyソースから狩りをすることができますWebKitの
EncodedJSValue JSC_HOST_CALL functionProtoFuncApply(ExecState * exec) {
JSValue thisValue = exec - > hostThisValue();
CallData callData;
CallType callType = getCallData(thisValue, callData);
if (callType == CallTypeNone) return throwVMTypeError(exec);
JSValue array = exec - > argument(1);
MarkedArgumentBuffer applyArgs;
if (!array.isUndefinedOrNull()) {
if (!array.isObject()) return throwVMTypeError(exec);
if (asObject(array) - > classInfo() == & Arguments::s_info) asArguments(array) - > fillArgList(exec, applyArgs);
else if (isJSArray(& exec - > globalData(), array)) asArray(array) - > fillArgList(exec, applyArgs);
else if (asObject(array) - > inherits(& JSArray::s_info)) {
unsigned length = asArray(array) - > get(exec, exec - > propertyNames().length).toUInt32(exec);
for (unsigned i = 0; i < length; ++i)
applyArgs.append(asArray(array) - > get(exec, i));
} else return throwVMTypeError(exec);
}
return JSValue::encode(call(exec, thisValue, callType, callData, exec - > argument(0), applyArgs));
}
にあります。私は自分で見つけることができませんでした。誰かが私をソースに向かわせたいなら、それは涼しいです:)
'console.dir(Function.prototype)'を実行し、矢印をクリックしてそのプロパティを表示してください。 –