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--
The main content of this article is to explain "javascript how to get a variable is a numeric type or a string type", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how javascript can get whether a variable is a numeric type or a string type.
In javascript, you can use the typeof operator to get whether a variable is a numeric type or a string type, syntax "typeof variable"; if the return value is "number", the variable is a numeric type, and if the return value is "string", the variable is a string type.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Does javascript determine whether the variable is a numerical type? Or a string type?
In javascript, you can use the typeof operator to determine whether a variable is of numeric type or string type.
The typeof operator is used to detect the data type of a given variable or value, and the returned value is the data type name of the Operand, which is a string result.
The format is as follows:
Typeof Operand
Note: the Operand can be a variable or a specific value (that is, literal). The returned values are as follows:
Undefined: indicates that the Operand is undefined
Boolean: indicates that the Operand is a Boolean
String: indicates that the Operand is a string
Number: indicates that the Operand is a number
Object: indicates that the Operand is an object or an array
Function: indicates that the Operand is a function.
Note: a function is also an object, but typeof treats a function as a special case, so when you detect a function, the result is function, not object.
An example of using the typeof operator to detect data types is as follows:
Var miaov = 'ketang'; / / declare the variable and assign a value to the variable console.log (typeof miaov); / / check the variable miaov, and the result is: stringconsole.log (typeof 1); / / detect the number 1, and the result is: numberconsole.log (typeof true); / / detect true, the result is: booleanconsole.log (typeof false); / / detect false, the result is: booleanconsole.log (typeof undefined); / / detect undefined, the result is undefinedconsole.log (typeof null) / / detect null, result: objectconsole.log (typeof {}); / / detect object, result: objectconsole.log (typeof []); / / detect array, result: objectfunction func () {} / / define function console.log (typeof func) / / check the func function type, the result is: 'function' so far, I believe you have a better understanding of "how to get a variable is a numeric type or a string type", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue 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.