Skip to content

Latest commit

 

History

History
11 lines (10 loc) · 1003 Bytes

native-host-objects.md

File metadata and controls

11 lines (10 loc) · 1003 Bytes

Native objects: These are core objects that are always accessible in JavaScript, regardless of the environment in which the code is running. They are defined in the ECMAScript specification and include objects like String, Math, RegExp, Object, Function, and others.

let str = new String("Hello World"); // Using the String built-in object
console.log(str); // "Hello World"

Host objects: These are objects provided by the host environment in which the JavaScript is running. In a browser environment, host objects include window, XmlHttpRequest, and DOM nodes. However, host objects can vary depending on the environment. For instance, when JavaScript is run in a server-side environment like Node.js, different host objects like global and process are available.

console.log(window.location.href); // Using the window host object in a browser environment
console.log(process.version); // Using the process host object in a Node.js environment