自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

JavaScript的兩大類內(nèi)建數(shù)據(jù)類型

開發(fā) 前端
JavaScript的數(shù)據(jù)類型在大的方向上分為兩類:1)primitive types and 2)object tyeps。

[[360739]]

 JavaScript的數(shù)據(jù)類型在大的方向上分為兩類:1)primitive types and 2)object tyeps。

其一 primitive types包括常規(guī)的 numbers,string, booleans 以及特殊類型的 null 和 undefined。而且以上五類都是immutuable types;

其二,object types 包括object,以及特殊類型的object即array。其他比如 Set,Map,typed array, RegExp and Date types.

一、Numbers

Numeric literal 表示 十六進(jìn)制,二進(jìn)制和八進(jìn)制:

  1. //integer literals 
  2. > 0xff 
  3. 255 
  4. > 0b1011 
  5. 11 
  6. > 0o377 
  7. 255 
  8. > 377 
  9. 377 
  10. //floating-point literals 
  11. undefined 
  12. > 6.02e23 
  13. 6.02e+23 
  14. > 1.47e-23 
  15. 1.47e-23 
  16. //Arithmetic  
  17. Math.hypo 
  18.  
  19. //Infinity 
  20. Infinity                    // A positive number too big to represent 
  21. Number.POSITIVE_INFINITY    // Same value 
  22. 1/0                         // => Infinity 
  23. Number.MAX_VALUE * 2        // => Infinity; overflow 
  24.  
  25. -Infinity                   // A negative number too big to represent 
  26. Number.NEGATIVE_INFINITY    // The same value 
  27. -1/0                        // => -Infinity 
  28. -Number.MAX_VALUE * 2       // => -Infinity 
  29.  
  30. NaN                         // The not-a-number value 
  31. Number.NaN                  // The same value, written another way 
  32. 0/0                         // => NaN 
  33. Infinity/Infinity           // => NaN 
  34.  
  35. Number.MIN_VALUE/2          // => 0: underflow 
  36. -Number.MIN_VALUE/2         // => -0: negative zero 
  37. -1/Infinity                 // -> -0: also negative 0 
  38. -0 
  39.  
  40. // The following Number properties are defined in ES6 
  41. Number.parseInt()       // Same as the global parseInt() function 
  42. Number.parseFloat()     // Same as the global parseFloat() function 
  43. Number.isNaN(x)         // Is x the NaN value? 
  44. Number.isFinite(x)      // Is x a number and finite? 
  45. Number.isInteger(x)     // Is x an integer
  46. Number.isSafeInteger(x) // Is x an integer -(2**53) < x < 2**53? 
  47. Number.MIN_SAFE_INTEGER // => -(2**53 - 1) 
  48. Number.MAX_SAFE_INTEGER // => 2**53 - 1 
  49. Number.EPSILON          // => 2**-52: smallest difference between numbers 
  50. // 浮點(diǎn)數(shù)  
  51. 18,437,736,874,454,810,627 只有這么多浮點(diǎn)數(shù),能被表示出來。 
  52. // rouding problems  
  53. //BigInt 
  54.  
  55. //Date and time 
  56. let timestamp = Date.now();  // The current time as a timestamp (a number). 
  57. let now = new Date();        // The current time as a Date object. 
  58. let ms = now.getTime();      // Convert to a millisecond timestamp
  59. let iso = now.toISOString(); // Convert to a string in standard format. 

 二、String and Text

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

 三、Boolean Values

只有 true 和 false 這兩項(xiàng)。

四、null and undefined

  1. > typeof(null
  2. 'object' 

 五、Symbols

  1. let s = Symbol.for("shared"); 
  2. let t = Symbol.for("shared"); 
  3. s === t          // => true 
  4. s.toString()     // => "Symbol(shared)" 
  5. Symbol.keyFor(t) // => "shared" 

 六、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)

七、Immutable Primitives and Mutable Object Referece

  1. function equalArray(a, b) { 
  2. ... if (a === b) return true
  3. ... if (a.length !== b.length) return false
  4. ... for (let i = 0; i < a.length; i++) { 
  5. ..... if (a[i] !== b[i]) return false
  6. ..... } 
  7. ... return true
  8. ... } 

 八、Type Conversions

implicite conversion and explicite conversions

九、Variable Declaration and Assignment

  1. // Destructuring Assignment 
  2. [x,y] = [x+1,y+1];  // Same as x = x + 1, y = y + 1 
  3. [x,y] = [y,x];      // Swap the value of the two variables 
  4. // Same as const sin=Math.sin, cos=Math.cos, tan=Math.tan 
  5. const {sin, cos, tan} = Math; 
  6. //此處與python的用法完全一致。 

 【編輯推薦】

 

責(zé)任編輯:姜華 來源: 今日頭條
相關(guān)推薦

2010-09-26 16:04:48

JVM內(nèi)存溢出

2010-05-07 16:13:07

Oracle歸檔模式

2010-06-11 17:01:09

Windows Pho

2010-06-09 10:38:07

UML類圖

2022-03-07 13:58:30

JavaScript原始數(shù)據(jù)前端

2016-08-18 14:13:55

JavaScript基本數(shù)據(jù)引用數(shù)據(jù)

2011-07-29 10:12:12

JavaScript

2015-10-22 10:44:50

2010-10-08 15:11:28

JavaScript數(shù)

2021-12-03 15:24:45

Javascript數(shù)據(jù)類型

2018-11-15 09:45:47

JavaScript數(shù)據(jù)類型變量

2019-09-28 22:41:18

OracleMySQL隱式數(shù)據(jù)

2010-10-08 09:02:03

JavaScript基

2021-10-13 09:50:02

鴻蒙HarmonyOS應(yīng)用

2017-02-27 08:34:09

JavaScript數(shù)據(jù)引用

2019-08-12 11:40:48

數(shù)據(jù)庫SQLite3數(shù)據(jù)類型

2022-08-12 16:12:34

JavaScript數(shù)據(jù)類型字符串

2010-09-17 16:18:43

Java內(nèi)存溢出

2010-08-30 10:03:13

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號