What does the built in object hierarchy look like in javascript?

↘锁芯ラ 提交于 2019-12-31 15:54:43

问题


I was looking for a diagram which shows the built in types of javascript like Function and String but on google I keep finding diagrams with the browser-related stuff like Window.

I'm just looking for the pure js object diagram. I know about the ECMA specification but I'm looking for a diagram because I'm a visual type.


回答1:


There's not much depth to the JavaScript types to speak of, the diagram would be fairly flat. It's basically (UML at the end):

  • primitive string
  • primitive number
  • primitive boolean
  • the Undefined type, which has exactly one instance: undefined
  • the Null type, which has exactly one instance: null
  • Symbol (a primitive type) (ES2015+)
  • Proxy (an object type, but one not backed by the default object prototype) (ES2015+)
  • Object
    • Number
    • String
    • Boolean
    • Function
    • Date
    • RegExp
    • Array
    • Math
    • Error
      • EvalError
      • RangeError
      • ReferenceError
      • SyntaxError
      • TypeError
      • URIError
    • JSON (ES5+)
    • ArrayBuffer (ES2015+)
    • DataView (ES2015+)
    • The typed arrays (Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array) (ES2015+)
    • Map (ES2015+)
    • WeakMap (ES2015+)
    • Set (ES2015+)
    • WeakSet (ES2015+)
    • Promise (ES2015+)
    • Reflect (ES2015+)

So in UML, something like this:

(click the image to open it so you can zoom)

Note that this is just JavaScript's type tree. It doesn't include lots of other things that are often used with JavaScript on browsers (such as the DOM, the worker's API, web storage, the File API, etc., etc.).



来源:https://stackoverflow.com/questions/19891453/what-does-the-built-in-object-hierarchy-look-like-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!