Project Docs Github
Log in
ittf site docs t _js wz bind.js.ittf Edit
  • /ittf/site/docs/t/_js/wz/bind.js.ittf

/ittf/site/docs/t/_js/wz/bind.js.ittf (primary)

edit
                                            
1 $group
2 # Credit to Douglas Crockford for this bind method​
3 if !(Function.prototype.bind)
4 set Function.prototype.bind =
5 function
6 param oThis
7 if typeof (this) !== "function"
8 throw
9 new TypeError ("Function.prototype.bind - what is trying to be bound is not callable")
10 var
11 decl aArgs = Array.prototype.slice.call(arguments, 1)
12 decl fToBind = this
13 decl fNOP
14 function
15 decl fBound
16 function
17 return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments)))
18 set fNOP.prototype = this.prototype
19 set fBound.prototype =
20 new fNOP ()
21 return fBound
Save
Save & Refresh
Cancel