SOURCE

console 命令行工具 X clear

                    
>
console
// !function () {
//   var anim = $.fn.animate
//   $.fn.animate = function () {
//     var args = $.makeArray(arguments)
//     var defer
//     if (args[3] === 'promise') {
//     } else if (args[2] === 'promise') {
//       args[2] = 'swing'
//     } else if (args[1] === 'promise') {
//       args[2] = 'swing'
//       args[1] = 'normal'
//     } else {
//       return anim.apply(this, args)
//     }
//     defer = $.Deferred()
//     args[3] = defer.resolve
//     anim.apply(this, args)
//     return defer.promise()
//   }
// } ()

!function () {
  var anim = $.fn.animate
  $.fn.animate = function () {
    var args = $.makeArray(arguments)
    var cb = args[args.length - 1]
    var defer
    if($.type(cb) === 'function') {
        return anim.apply(this, args)
    } else {
        defer = $.Deferred()
        args.push(defer.resolve)
        anim.apply(this, args)
        return defer.promise()
    }
  }
} ()

// var $box = $('.box')
// $box.animate({ 'left': '100px' }, 'promise')
//     .then(function () {
//       $box.animate({ 'top': '100px' }, 'promise')
//     }).then(function () {
//       $box.animate({ 'left': '200px' }, 'promise')
//     }).then(function () {
//       $box.animate({ 'top': '200px' }, 'promise')
//     }).then(function () {
//       $box.fadeOut(1500, 'promise').then(function() {
//           $box.css('background-color', 'green')
//       })
//     }).then(function () {
//       $box.fadeIn(1500)
//     })
var $box = $('.box')
$box.animate({ 'left': '100px' })
    .then(function () {
      $box.animate({ 'top': '100px' })
    }).then(function () {
      $box.animate({ 'left': '200px' })
    }).then(function () {
      $box.animate({ 'top': '200px' })
    }).then(function () {
      $box.fadeOut(1500).then(function() {
          $box.css('background-color', 'green')
      })
    }).then(function () {
      $box.fadeIn(1500)
    })
<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>

<div class="box"></div>
.box {
  position: relative;
  height: 100px;
  width: 100px;
  margin: 50px;
  background-color: red;
}