今天,我看到了以下代码片段:
/**
* @param src: any variable of any type
* @param html: output format (true|false); default = false
* @param level: (internal, don't use)
*
* @return string: formatted output
*/
function showObj(src, html, level) {
level |= 0;
完整的脚本:https : //codereview.stackexchange.com/questions/123283/helper-function-to-format-output-any-type-of-variable
| =(在“级别| = 0”中)的值分配是什么?
我以前从没见过它,也找不到任何东西。
That(|
)是按位运算符,通常用于必须将数字的小数点截断的情况。
var level = 2.444434;
level |= 0; // level = level | 0;
console.log(level) // 2
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句