Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.length >>> 0 这个是什么意思? #150

Closed
tomheng opened this issue Dec 31, 2011 · 3 comments
Closed

this.length >>> 0 这个是什么意思? #150

tomheng opened this issue Dec 31, 2011 · 3 comments

Comments

@tomheng
Copy link

tomheng commented Dec 31, 2011

es5-safe.js中this.length >>> 0 是什么意思啊?

对js不是很熟悉,看了stackoverflow上的一写讨论还是没有彻底搞明白。

烦请不吝赐教

@lifesinger
Copy link
Member

这个可以看 ECMAScript 的相关章节
可以用来将:

  1. 所有非数值转换成0
  2. 所有大于等于 0 等数取整数部分

这样可以使得程序很 robust

@tomheng
Copy link
Author

tomheng commented Jan 4, 2012

嗯,明白了,>>> 无符号右移运算符 :)

@qiangtou
Copy link

qiangtou commented Jul 1, 2013

我在backbone.localStorage.js里面看到和0做或运算也能起到同样的效果,还支持负数

1|0
1.1|0
'asfdasfda'|0
0|0
(-1)|0
(-1.5646)|0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants