比如我有如下代码
var eightBall = { index: 0,
advice: ["yes", "no", "maybe", "not a chance"],
shake: function() {
this.index = this.index + 1;
if (this.index >= this.advice.length) { this.index = 0;
} },
look: function() {
return this.advice[this.index];
}
};
eightBall.shake(); console.log(eightBall.look());
希望得到如图结果:
那么我需要多次执行最后一行代码,在开发者工具中应该如何做呢?
优化一下楼上答案.