@@ -3,6 +3,7 @@ var global = require('../internals/global');
3
3
var uncurryThis = require ( '../internals/function-uncurry-this' ) ;
4
4
var aCallable = require ( '../internals/a-callable' ) ;
5
5
var isObject = require ( '../internals/is-object' ) ;
6
+ var hasOwn = require ( '../internals/has-own-property' ) ;
6
7
var arraySlice = require ( '../internals/array-slice' ) ;
7
8
8
9
var Function = global . Function ;
@@ -11,7 +12,7 @@ var join = uncurryThis([].join);
11
12
var factories = { } ;
12
13
13
14
var construct = function ( C , argsLength , args ) {
14
- if ( ! ( argsLength in factories ) ) {
15
+ if ( ! hasOwn ( factories , argsLength ) ) {
15
16
for ( var list = [ ] , i = 0 ; i < argsLength ; i ++ ) list [ i ] = 'a[' + i + ']' ;
16
17
factories [ argsLength ] = Function ( 'C,a' , 'return new C(' + join ( list , ',' ) + ')' ) ;
17
18
} return factories [ argsLength ] ( C , args ) ;
@@ -20,12 +21,13 @@ var construct = function (C, argsLength, args) {
20
21
// `Function.prototype.bind` method implementation
21
22
// https://tc39.es/ecma262/#sec-function.prototype.bind
22
23
module . exports = Function . bind || function bind ( that /* , ...args */ ) {
23
- var fn = aCallable ( this ) ;
24
+ var F = aCallable ( this ) ;
25
+ var Prototype = F . prototype ;
24
26
var partArgs = arraySlice ( arguments , 1 ) ;
25
27
var boundFunction = function bound ( /* args... */ ) {
26
28
var args = concat ( partArgs , arraySlice ( arguments ) ) ;
27
- return this instanceof boundFunction ? construct ( fn , args . length , args ) : fn . apply ( that , args ) ;
29
+ return this instanceof boundFunction ? construct ( F , args . length , args ) : F . apply ( that , args ) ;
28
30
} ;
29
- if ( isObject ( fn . prototype ) ) boundFunction . prototype = fn . prototype ;
31
+ if ( isObject ( Prototype ) ) boundFunction . prototype = Prototype ;
30
32
return boundFunction ;
31
33
} ;
0 commit comments