Fre*_*ind 45 javascript operators bitwise-operators mongoose comparison-operators
我!!~在阅读时在代码中发现了一个奇怪的内容:https://github.com/LearnBoost/mongoose/blob/master/lib/document.js#L678
Document.prototype.isModified = function (path) {
return !!~this.modifiedPaths.indexOf(path);
};
Run Code Online (Sandbox Code Playgroud)
我读过那是什么!! (不是)JavaScript中的运算符?以及如何:〜运算符?; 为什么作者!!~在这里使用?
我试过了:
!!~1 // -> true
!!~0 // -> true
!!~-1 // -> false
!!~-2 // -> true
Run Code Online (Sandbox Code Playgroud)
似乎它只是false在数字的时候-1.这样对吗?为什么不核对一下电话号码是不是-1还是>=0?
| 归档时间: |
|
| 查看次数: |
5421 次 |
| 最近记录: |