JavaScript 高阶函数

; Run = function ()
  {
    ; return Array.prototype.splice.call( arguments, -1 )[0].apply( this, arguments )
  }

; Loop = function ()
  {
    var
      count = -1
    , end   = arguments.length -1
    , _func = arguments[ end ]

    ; while ( ++count < end )
      {
        ; _func.apply( this, arguments[ count ] )
      }
  }

; Run( 2, 3, 4, function( x, y, z )
  {
      console.log( x*y*z )
  })
; Run.call( { name : 'Run' }, 2, 3, 4, function( x, y, z )
  {
      console.log( this, x*y*z )
  })
; Loop( [ 2, 3 ], [ 4, 5 ], function ( x, y )
  {
    ; console.log( x*y )
  })
; Loop.call( { name : 'Loop' }, [ 2, 3 ], [ 4, 5 ], function ( x, y )
  {
    ; console.log( this, x*y )
  })
原文地址:https://www.cnblogs.com/doop/p/3943951.html