In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the short circuit in the JavaScript logic operator, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
1. A short circuit only exists in & & and | |. When certain conditions are met, the code on the right will not be executed.
/ / logical and & & console.log (false & & 20) / / falseconsole.log (5 < 3 & & 20) / / falseconsole.log (undefined & & 20) / / undefinedconsole.log (null & & 20) / / nullconsole.log (0 & & 20) / / 0console.log (10 & & 20) / / 20 / / logical OR | console.log (false | | 20) / / 20console.log (5 < 3 | 20) / 20console.log (undefined | 20 | 20) ) / / 20console.log (null | | 20) / / 20console.log (0 | | 20) / / 20console.log (10 | | 20) / / 10
2. It is often used for functions to pass the integrity of parameters. If no parameters are passed on the left, they are executed. If parameters are passed, parameters are executed.
Function getSum (XMague y) {x = x | | 0 / / if no parameter is passed on the left, execute y = y | 0 / / if the parameter is passed, execute the parameter return x + y} let sum = getSum (XMague y) console.log (sum) Thank you for reading this article carefully. I hope the article "what are the short circuits in JavaScript logic operators" shared by the editor will be helpful to you? At the same time, I also hope that you will support and pay attention to the industry information channel, and more related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.