“短路求值(Short-Circuit Evaluation)
生活随笔
收集整理的這篇文章主要介紹了
“短路求值(Short-Circuit Evaluation)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
// 邏輯與和邏輯或操作符總是先計算其做操作數,只有在僅靠左操作數的值無法確定該邏輯表達式的結果時,才會求解其右操作數。 function aa() {if (null) { console.log('null') }if (undefined) { console.log('undefined') }if (false) { console.log('false') }if (true) { console.log('true') }if (NaN) { console.log('NaN') }if ("") { console.log('""') }if ("11") { console.log('11') }if (1) { console.log('1') }}aa()console.log(('123' || 'Fetching Data'))//123
console.log((null|| 'Fetching Data'))//Fetching Data
console.log((null&& 'Fetching Data'))//null 有錯 返回第一個錯 ; 都對 最后一個對
console.log(('123'&& 'Fetching Data'))//Fetching Data// 快速Float轉Integer
console.log(23.9 | 0); // Result: 23
console.log(-23.9 | 0); // Result: -23
console.log(1553 / 10 | 0) // Result: 155
?
轉載于:https://www.cnblogs.com/zjicmhahah/p/10783911.html
總結
以上是生活随笔為你收集整理的“短路求值(Short-Circuit Evaluation)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: A Hands-on Look at U
- 下一篇: 4.28—013—周日