What are the host and native objects of JS?

what are the host and native objects of 1:JS?
2: why is it not a good idea to extend JS built-in objects?
3: what are the built-in objects and built-in functions?

Aug.04,2021

to know what the host objects of JS are, you first need to know what the hosts are, so that you can find out what the host objects are by looking at the objects owned by the host for different hosts.

and the host of JS depends on where JS runs .
normally we will run JS, in the browser, so the host is the browser, and the top-level objects in the browser are all host objects. Such as: window, document and so on.

Common hosts

  1. you can run Node environment
  2. of V8.
  3. webview component environments in some other languages, such as QTWebview environment,
  4. in the CPP language QT.
  5. Puppeteer simulated chrome environment, etc.

and these host objects you can look up through the relevant components or library documents host objects provided by different environments , some will have additional host objects, depending on the function of the component itself.

refers to the ECMAScript language object specified in the W3C specification, which is implemented by the JS engine.

for example, in the specification directory,

clipboard.png

these chapters are all about language objects.

you can see all the language objects, common global objects, Reflect,Date, etc.

from these chapters.

Host objects refer to native objects such as Document and window, but there are already some methods in browsers, such as Array object, which are JS built-in objects, and they are uncertain. You don't know when the browser or javascript itself will implement this method, and it is inconsistent with your extended implementation, which may cause the code you write to collapse. As for built-in objects and built-in functions, if Math,Boolean and other built-in functions are built-in functions, alert and confirm are more classic. Of course, there are many other landlords who can search


on their own.
  1. extending JS built-in objects can pollute the global code, because you may not know where to use native methods, which is very bad for development and post-maintenance.
  2. Open the chrome console and create an object. When using this object, most of the drop-down box prompts without > are built-in methods, but it is also possible to include methods encapsulated by Chrome itself.

example

var a = []
a.

or find an online API document and take a look at it. =

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32c8d-2b68c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32c8d-2b68c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?