Object.defineProperty 存在 bug
var binder = function () { if (this instanceof bound) { // 15.3.4.5.2 [[Construct]] // When the [[Construct]] internal method of a function object, F that was created using the bind function is called with a list of arguments ExtraArgs, the following steps are taken: // 1. Let target be the value of F's [[TargetFunction]] internal property. // 2. If target has no [[Construct]] internal method, a TypeError exception is thrown. // 3. Let boundArgs be the value of F's [[BoundArgs]] internal property. // 4. Let args be a new list containing the same values as the list boundArgs in the same order followed by the same values as the list ExtraArgs in the same order. // 5. Return the result of calling the [[Construct]] internal method of target providing args as the arguments. var result = apply.call( target, this, array_concat.call(args, array_slice.call(arguments)) ); if ($Object(result) === result) { return result; } return this; } // 15.3.4.5.1 [[Call]] // When the [[Call]] internal method of a function object, F that was created using the bind function is called with a list of arguments ExtraArgs, the following steps are taken: // 1. Let target be the value of F's [[TargetFunction]] internal property. // 2. If target has no [[Call]] internal method, a TypeError exception is thrown. // 3. Let boundArgs be the value of F's [[BoundArgs]] internal property. // 4. Let args be a new list containing the same values as the list boundArgs in the same order followed by the same values as the list ExtraArgs in the same order. // 5. Return the result of calling the [[Call]] internal method of target providing args as the arguments. var result = apply.call( target, this, array_concat.call(args, array_slice.call(arguments)) ); if ($Object(result) === result) { return result; } return this; };
内容来源: es-shims/es5-shim