0

索引是一个数字。我不明白JavaScript 中的>>是什么。

setIndex: function(index) {

    var i = this.index;
    this.index = index >> 0; // ?????

    if (this.index < 0) {
    this.index = 0;

    } else if (this.index >= this.config.items.length) {
    this.index = this.config.items.length - 1;
    }

    return (i !== this.index);
}
4

1 回答 1

2

x >> y means to shift the bits of x by y places to the right (<< means shift to the left).

Read more about bitwise operators and see some examples here.

于 2013-08-09T09:27:29.217 回答