In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor, let's share with you how JavaScript simplifies if. Else, I believe that most people do not know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it together.
Simplify if... Else
If...else is so common that many people forget that there are other ways to judge conditions. For example, for a simple variable assignment, there is no need to use such a lengthy statement, and one-line expression is done:
/ / novice let test= boolean; if (x > 100) {test= true;} else {test= false;} / / abbreviated expression let test= (x > 10)? True: false; / / more direct let test = x > 10; console.log (test)
Ternary expressions can make complex conditional bifurcation judgments, but at the expense of some readability:
Let x = 300, let test2 = (x > 100)? 'greater 100': (x < 50)? 'less 50': 'between 50 and 100'; console.log (test2); / / "greater than 100" JavaScript is the abbreviation of JavaScript, it is a literal scripting language, its interpreter is called JavaScript engine, is a part of the browser, mainly used for web development, can add a variety of dynamic effects to the website, make the page more beautiful.
The above is all the contents of the article "how JavaScript simplifies if... else". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.