What’s the difference between host objects and native objects?

What is a host object?

Host objects are inherent to the environment. For the browser, this includes objects like window, document. Since they depend from the ‘host’ (environment), the behaviour could be different!

1
2
3
4
5
6
var obj = {         // Native Object - no risk, same behaviour everywhere
  name: 'John',
  gender: 'male'
}

var myRequest = new XMLHttpRequest();   // Host object

###hat is a native object?

Native objects are inherit from ECMAScript language. So long as you’re writing in javascript you may always use them. It doesn’t matter if you are running Chrome, Firefox or Internet Explorer or even if you’re just in Node JS, you’ve got access to the native objects.

NOTE Any object that is not native is a host object.

Resources: