In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "javascript how to detect the definition of variables", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "javascript how to detect whether variables are defined" bar!
Javascript method to detect whether the variable is defined: 1, use the typeof operator to obtain the data type of the variable, syntax "typeof variable name"; 2, through the "=" operator to determine whether the data type obtained is the "undefined" type, if it is not defined, otherwise it is defined.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Undefined is also a special data type with only one value, indicating that it is undefined. For undeclared variables, looking at their types using the typeof operator reveals that the undeclared variable is undefined:
So we can first use the typeof operator to get the data type of the javascript variable, and then determine whether the data type obtained is of type "undefined". If so, it is not defined, and vice versa.
If (typeof b = = "undefined") {console.log ("undefined");} else {console.log ("definition");}
Output:
Thank you for your reading, the above is the content of "how javascript detects whether variables are defined". After the study of this article, I believe you have a deeper understanding of how javascript detects whether variables are defined, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.