In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "there are several data types in javascript". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "there are several data types in javascript".
There are eight data types in javascript, which are number, string, boolean, null, undefined, symbol, bigint and object.
This article operating environment: windows10 system, javascript 1.8.5, thinkpad T480 computer.
First of all, in js, data types are divided into original data types and reference data types.
Original data type
Number
String
Boolean
Null
Undefined
Symbol (ES6)
Bigint (ES10)
Reference data type
Object
Include function/array/object in the reference data type object
We can see here that there are a total of eight data types.
New to ES6: Symbol
This data type is mainly used to create a unique identity, no nonsense, on the code:
Let obj = {}; obj.a = 1 * * let a = Symbol (); obj [a] = 2; / / is the an inside obj 1 or 2 at this time? We can print obj obj {a: 1 Symbol (): 2 _ _ proto__: Object} / / at this point we can find that the defined variable a seems to be just a flag and does not have a specific attribute name.
Symbol can pass a string when executing, for example:
Let obj = {}; obj.a = 1 let a = Symbol ('a'); obj [a] = 2; obj {a: 1 Symbol (a): 2 / / Symbol with a string is better able to distinguish each unique identity _ _ proto__: Object}
New to ES10: Bigint
We all know that there is a problem with the accuracy of limit values in javascript, for example:
Let a = Number.MAX_SAFE_INTEGER; / / 9007199254740991 maximum safe integer console.log (a + 1); / / 9007199254740992console.log (a + 2); / / 9007199254740992console.log (a + 1 = a + 2); / / true// at this time, we can find that the values calculated by a + 1 and a + 2 are the same, although they can be calculated normally, but they have lost the value of calculation.
At this time, we can find that the values calculated by a + 1 and a + 2 are the same, although they can be calculated normally, they have lost the value of calculation.
BigInt is a built-in object that provides methods for representing values other than the maximum safe integer, and bigint is typically used to calculate values other than the maximum safe integer:
BigInt (1) = = BigInt ('1') = 1n so far, I believe you have a deeper understanding of "several data types in javascript". 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.