In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what JScript data types are, and the editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Jscript has three main data types, two composite data types, and two special data types.
The main (basic) data types are:
String
Numerical value
Boolean
The composite (reference) data types are:
Object
Array
The special data types are:
Null
Undefined
String data type
A string value is a string of zero or more Unicode characters (letters, numbers, and punctuation) arranged together. The string data type is used to represent text in Jscript. Scripts can contain string text, which is enclosed in matching single or double quotation marks. The string can contain double quotation marks, either single quotation marks or single quotation marks, and double quotation marks on both sides of the single quotation marks. The following is an example of a string:
"Happy am I; from care I'm free!"
"Avast, ye lubbers!" Roared the technician.
"42"
C
Note that there is no type in Jscript that represents a single character. To represent a single character in a Jscript, create a string that contains only one character. A string containing zero characters ("") is an empty (zero length) string.
Numeric data type
There is no difference between integer and floating-point values in Jscript; Jscript values can be either (all values are represented as floating-point values within Jscript).
Integer value
Integer values can be positive integers, negative integers, and 0. It can be expressed in decimal, octal and hexadecimal. In Jscript, most numbers are represented in decimal system. The prefix "0" indicates an octal integer value that can only contain numbers from 0 to 7. A number prefixed with "0" and containing the number "8" or "9" is interpreted as a decimal number.
Prefix "0x" (zero and x | X) indicates a hexadecimal integer value. Can contain the numbers 0 to 9 and the letters A to F (uppercase or lowercase). Use the letters A to F to represent a single number in decimal 10 to 15. That is to say, 0xF is equal to 15 and 0x10 is equal to 16.
Octal and hexadecimal numbers can be negative, but cannot have decimal places and cannot be expressed by scientific counting (index).
Floating point value
The floating point value is a number with a decimal part. It can also be expressed by scientific counting. That is to say, uppercase or lowercase "e" is used to indicate the power of 10. Jscript is an 8-byte IEEE754 floating-point standard expressed as a numeric value. This means that the number can range from ±1.7976931348623157x10308 to ±5x10-324. A number that begins with "0" and contains a decimal point is interpreted as a decimal floating point.
Note that a number that begins with "0x" or "00" and contains a decimal point will have an error. The following is an example of numbers in Jscript.
Digital description equivalent decimal number
. 0001, 0.0001, 1e-4, 1.0e-4 four equal floating point numbers. 0.0001
345 floating point numbers. three hundred and forty five
42 integers. forty-two
0378 whole number. Although it looks like an octal number (starting with 0), 8 is not a valid octal number, so it is a decimal number. three hundred and seventy eight
0377 octal integers. Note that although it looks 1 smaller than the number above, the actual value is very different. two hundred and fifty five
0.0001 floating point numbers. Although it starts with zero, it is not an octal number because it has a decimal point. 0.0001
00.0001 error. The beginning of two zeros is represented as octal, but octal numbers cannot have decimal parts. NCMA (compilation error)
0Xff hexadecimal integer. two hundred and fifty five
0x37CF hexadecimal integer. 14287
0x3e7 hexadecimal integer. Note that'e'is not considered an index. nine hundred and ninety nine
0x3.45e2 error. Hexadecimal numbers cannot have decimal parts. NCMA (compilation error)
In addition, Jscript contains special value numbers. They are:
NaN (not a number). Used when performing mathematical operations on inappropriate data, such as strings or undefined values.
Positive infinity. In Jscript, if a positive number is too large, use it to represent it.
Negative infinity. In Jscript, it is used to represent a negative number if it is too large.
Positive 0 and negative 0. Jscript distinguishes positive 0 from negative 0.
Boolean data type
Although string and numeric types can have countless different values, the Boolean data type has only two values. They are the words true and false. The Boolean value is a true value that indicates the validity of a state (indicating whether the state is true or false).
Comparisons in scripts usually result in a Boolean result. Consider the next line of Jscript code.
Y = (x = = 2000)
Here we compare whether the value of the variable x is equal to the number 2000. If equal, the result of the comparison is the Boolean value true, which is assigned to the variable y. If x is different from 2000, the result of the comparison is the Boolean value false.
Boolean values are particularly useful in structural control. You can combine a comparison that creates a Boolean value directly with statements that use that Boolean value. Consider the following example of Jscript code.
If (x = = 2000)
Z = z + 1
Else
X = x + 1
When the Boolean value is true, the if/else statement in Jscript performs one operation (thus, z = z + 1), and when the Boolean value is false, another operation is performed (x = x + 1).
You can use any expression to compare expressions. Any expression with a value of 0, null, undefined, or empty string is interpreted as false. Expressions for other arbitrary values are interpreted as true. For example, you can use the following expression:
If (x = y + z) / / this may not be the desired result? As follows!
Note that the above code does not check whether x is equal to yyogz because only an equal sign (assignment) is used. Instead, the above code assigns yroomz to the variable x and then checks to see if the value of the entire expression is zero. To check that x is equal to yyogz, use the following code.
If (x = = y + z) / / this is different from the code above!
For more information about the comparison, see the flow of the control program.
Null data type
In Jscript, the data type null has only one value: null. The keyword null cannot be used as the name of a function or variable.
Variables that contain null contain "no value" or "no object". In other words, the variable does not hold a valid number, string, Boolean, array, or object. You can clear the contents of a variable by assigning a null value to it.
Note that in Jscript, null is not equal to 0 (unlike in C and C++). It should also be noted that the typeof operator in Jscript reports that the null value is of type Object, not of type null. This potential confusion is for backward compatibility.
Undefined data type
The undefined value is returned as follows:
Object property does not exist
A variable is declared but never assigned.
Note that you cannot test the existence of a variable by comparing it with undefined, although you can check whether it is of type "undefined". In the following code example, suppose the programmer wants to test whether the variable x has been declared:
/ / this method does not work
If (x = = undefined)
/ / do some operations
/ / this method also doesn't work-must be checked
/ / string "undefined"
If (typeof (x) = = undefined)
/ / do some operations
/ / this method is effective
If (typeof (x) = = "undefined")
/ / do some operations
Consider comparing the undefined value to the null.
SomeObject.prop = = null
The result of the comparison is true when
If the property someObject.prop contains a null value
If the property someObject.prop does not exist.
To check whether an object property exists, you can use the new in operator:
If ("prop" in someObject)
/ / someObject has attribute prop
This is the end of this article on "what are the JScript data types?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.