- call:
- Function.prototype.$call = function(context) {
- var context = context || Windows;
- context.fn = this;
- var args = Array.from(arguments).slice(1)
- context.fn(...args)
- delete context.fn;
- }
- apply:
- Function.prototype.$apply = function(context) {
- var context = context || Windows;
- context.fn = this;
- var args = Array.from(arguments[1])
- context.fn(...args)
- delete context.fn;
- }
- bind:
- Function.prototype.$apply = function(context) {
- var context = context || Windows;
- context.__proto__.fn = this;
- var args = Array.from(arguments).slice(1)
- return function(){
- var args2 = Array.from(arguments)
- context.fn(...args,...args2)
- delete context.__proto__.fn
- }
- }
来源: http://www.bubuko.com/infodetail-3506093.html