In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you what the original type of javascript, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
There are six primitive types of javascript: 1, number (numeric type), 2, string (string type), 3, null;4, undefined (undefined), 5, boolean (Boolean type), 6, symbol, which represents a unique value.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
After the standardization of JS1997 year, six built-in types are defined, including five Primitive types and one reference type, and ES6 adds another primitive type-symbol. Let's analyze these six built-in primitive types one by one:
Six primitive types
They are:
Number
String
Null
Undefined
Boolean
Symbol
1 、 number
Unlike other programming languages, all numbers in JavaScript are represented by floating-point values. JavaScript represents numbers in a 64-bit floating-point format defined by the IEEE-754 standard. In practice, however, JavaScript is based on 32-bit integers. In addition, it should be noted that there are numerous real numbers, but JavaScript can only represent a limited number of them in the form of floating-point numbers, that is, when real numbers are used in JavaScript, they are often just an approximate representation of real values.
2 、 string
A string (string) is an immutable ordered sequence of 16-bit values, each character usually from the Unicode character set, and the index of the JavaScript string is zero-based. The direct amount of a string in a JavaScript program is a sequence of characters enclosed by single or double quotation marks. In ECMAScript3, the direct quantity of a string must be written on one line, while in ECMAScript5, the direct quantity of a string can be split into several lines, but each line must end with a backslash (), which is not the content of the direct quantity of a string.
The backslash () mentioned above has a special use in JavaScript strings. Adding a character after the backslash symbol no longer indicates their literal meaning. For example,\ n is an escape character, which represents a newline character.
In addition, in ES5, a string can be treated as a read-only array, and in addition to using the charAt () method, you can also use square brackets to access individual characters in the string:
3 、 null
Null is the keyword of the JavaScript language. It represents a special value and is often used to describe a "null value". Performing the typeof operation on null returns the string "object", which was originally a flaw in the JavaScript design, but was gradually accepted as a placeholder for object. Represents an object that does not yet exist, often used to indicate that a function attempts to return an object that does not exist, and Null means "no object", that is, there should be no value there.
Typeof (null) result: "object"
4 、 undefined
When the declared variable has not been initialized, the default value of the variable is undefined, which means "missing value", which means that there should be a value here, but it has not been defined yet. Undefined is a predefined global variable whose value is "undefined". In ES3, undefined is a read / write variable that can be assigned any value. This bug is fixed in ES5, where undefined is read-only. If you use the typeof operator to get the type of undefined, "undefined" is returned, indicating that the value is the only member of the type.
Typeof (undefined) result: "undefined"
5 、 boolean
Boolean values refer to true or false, on or off, yes or no. This type has only two values, the reserved words true and false. The value of any JavaScript can be converted to a Boolean. Some of the following types are converted to false,undefined, null, 0,-0, NaN, "" / / empty strings, and all other values, including all objects (arrays), are converted to true. The common operators for Boolean values are "&", "| |", "!".
6 、 Symbol
Symbol is a new data type of ES6 that represents a unique value, and the greatest use of Symbol is to define the only property name of an object. The object attribute names of ES5 are all strings, which can easily cause the conflict of attribute names. If you use an object provided by someone else, but want to add a new method for a period of time, the name of the new method may conflict with the existing method. Therefore, you need to ensure that the name of each attribute is unique to prevent conflicts between attribute names. This is why ES6 introduced Symbol.
The above is all the content of this article "what are the original types of javascript"? 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.