Javascript:函数非异步调用顺序不正确

Javascript:函数非异步调用顺序不正确,javascript,asynchronous,Javascript,Asynchronous,我有这个: 问题在于这两个功能: this.addShipTest1 = function() { this.revolutionTime += 0.5; this.stopAllShipCSS(); this.addShip() } this.addShipTest2 = function() { this.revolutionTime += 0.5; this.stopAllShipCSS(); var save = this; s

我有这个:

问题在于这两个功能:

this.addShipTest1 = function() {
    this.revolutionTime += 0.5;
    this.stopAllShipCSS();
    this.addShip()
}

this.addShipTest2 = function() {
    this.revolutionTime += 0.5;
    this.stopAllShipCSS();

    var save = this;
    setTimeout(function() {
        save.addShip();
    }, 100);
}
为什么我要等着做这件事?我的意思是这些函数不是异步的,所以应该是异步的

addShip()
之后才被叫来

stopAllShipCSS()
问题是,在addShipTest1中,停止是“callafter”或“ignore”。。。(JSFiddle显示了问题)

编辑:

我尝试过解决方案,但没有成功:

(1)
$.when(this.stopAllShipCSS()).then(this.addShip());

(2)
var it = 0;
var save = this;
this.ships.forEach(function(ship) {
  ship.css({
    'animation':''
  });
  it++;
  if (it == save.ships.length) {
    save.addShip();
   }
});

这是因为它们是异步的。您能告诉我们stopAllShipCSS()的功能吗?当我使用剑道的时候,我一直都会遇到这种情况,我认为剑道的一些调用是异步的。哪一个?我尝试使用这个属性$.when(this.stopAllShipCSS())。然后(this.addShip())但是它不起作用。这里到底是什么问题?你的解释不太清楚。发生了什么,你期望发生什么?不,小提琴没有显示问题。如果我在
stopAllShipCSS()
中添加
console.log()
,它总是在调用
addShip()
之前发生。