Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the two built-in data types of JavaScript

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

JavaScript's two categories of built-in data types, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

The data types of JavaScript are divided into two categories in the general direction: 1) primitive types and 2) object tyeps.

One of the primitive types includes conventional numbers,string, booleans and special types of null and undefined. And the above five categories are all immutuable types.

Second, object types includes object, and a special type of object, namely array. Others, such as Set,Map,typed array, RegExp and Date types.

1. Numbers

Numeric literal stands for hexadecimal, binary, and octal:

/ / integer literals > 0xff 255 > 0b1011 11 > 0o377 255 > 377,377 / / floating-point literals undefined > 6.02e+11 trillion 6.02e+23 > 1.47e-23 1.47e-23 / / Arithmetic Math.hypo / / Infinity Infinity / / A positive number too big to represent Number.POSITIVE_INFINITY / / Same value 1Unip 0 / / = > Infinity Number.MAX_VALUE * 2 / / = > Infinity Overflow-Infinity / / A negative number too big to represent Number.NEGATIVE_INFINITY / / The same value-1 Number.MAX_VALUE 0 / / >-Infinity-Number.MAX_VALUE * 2 / / = >-Infinity NaN / / The not-a-number value Number.NaN / / The same value Written another way 0ap0 / / = > NaN Infinity/Infinity / / = > NaN Number.MIN_VALUE/2 / / = > 0: underflow-Number.MIN_VALUE/2 / / = >-0: negative zero-1/Infinity / /->-0: also negative 0-0 / / The following Number properties are defined in ES6 Number.parseInt () / / Same As the global parseInt () function Number.parseFloat () / / Same as the global parseFloat () function Number.isNaN (x) / / Is x the NaN value? Number.isFinite (x) / / Is x a number and finite? Number.isInteger (x) / / Is x an integer? Number.isSafeInteger (x) / / Is x an integer-(2pm / 53)

< x < 2**53? Number.MIN_SAFE_INTEGER // =>

-(2 cycles 53-1) Number.MAX_SAFE_INTEGER / / = > 2 cycles 53-1 Number.EPSILON / / > 2 colors 52: smallest difference between numbers / / floating point numbers 18437736874454810627 only so many floating point numbers can be expressed. / / rouding problems / / BigInt / / Date and time let timestamp = Date.now (); / / The current time as a timestamp (a number). Let now = new Date (); / / The current time as a Date object. Let ms = now.getTime (); / / Convert to a millisecond timestamp. Let iso = now.toISOString (); / / Convert to a string in standard format.

II. String and Text

/ / 1.string literals / 2.escape sequences / / 3.string methods / / 4.template literals (tagged template literals) / / 5.Pattern Matching / [1-9] [0-9] * /

III. Boolean Values

There are only true and false.

IV. Null and undefined

> typeof (null) 'object'

5. Symbols

Let s = Symbol.for ("shared"); let t = Symbol.for ("shared"); s = = t / / = > true s.toString () / / = > "Symbol (shared)" Symbol.keyFor (t) / / = > "shared"

VI. Global

Global constants like undefined, Infinity, and NaN

Global functions like isNaN (), parseInt () (§3.9.2), and eval () (§4.12)

Constructor functions like Date (), RegExp (), String (), Object (), and Array () (§3.9.2)

Global objects like Math and JSON (§6.8)

7. Immutable Primitives and Mutable Object Referece

> function equalArray (a, b) {... If (a = = b) return true;... If (a.length! = = b.length) return false;... For (let I = 0; I < a. Resume; iTunes +) {. If (a [I]! = b [I]) return false;. }... Return true;...}

VIII. Type Conversions

Implicite conversion and explicite conversions

IX. Variable Declaration and Assignment

/ / Destructuring Assignment [xQuery y] = [xprimel record1]; / / Same as x = Xero1Magi y = ycompany1 [xrecedy] = [yscot x]; / / Swap the value of the two variables / / Same as const sin=Math.sin, cos=Math.cos, tan=Math.tan const {sin, cos, tan} = Math; / / this is exactly the same as the usage of python. Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report