2

I suppose a definition of native and built-in objects is required to answer this question. Here's what the ECMAScript spec defines these as:

4.3.6 native object

object in an ECMAScript implementation, independent of the host environment, that is present at the start of the execution of an ECMAScript program.

NOTE Standard native built-in objects are defined in this specification. Some native objects are built-in; others may be constructed during the course of execution of an ECMAScript program

4.3.7 built-in object

object supplied by an ECMAScript implementation, independent of the host environment, that is present at the start of the execution of an ECMAScript program

NOTE Standard built-in objects are defined in this specification, and an ECMAScript implementation may specify and define others. Every built-in object is a native object. A built-in constructor is a built-in object that is also a constructor.

I'm looking forward to an explanation of this one.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Leila Hamon
  • 2,505
  • 7
  • 24
  • 32
  • 1
    I suppose "ruing" should be spelled "during"... – Bergi Jul 24 '12 at 14:16
  • @Bergi - It should, and it is, in the [annotated ES5 spec](http://es5.github.com/#x4.3.6). – James Allardice Jul 24 '12 at 14:17
  • ...and also in the original PDF; I fixed it. @OP: Where did you copy that? – Bergi Jul 24 '12 at 14:21
  • @LeilaHamon - Your excerpt which looks like it's from the spec doesn't actually match the ES5 spec... where is it from? (It's a bit closer to the ES3 spec, but your question is tagged [ecmascript-5]). – James Allardice Jul 24 '12 at 14:21
  • 1
    **See [this answer](http://stackoverflow.com/questions/8052578/what-is-an-ecmascript-native-object#8053011) for a good explanation**. – rsp Jul 24 '12 at 14:29
  • Yeah, I mistyped, it was early, so that's a valid excuse, right? :) I typed the definition of built-in object as the native object. – Leila Hamon Jul 24 '12 at 23:28

2 Answers2

4

Here is what ES5 shows:

4.3.6 native object # Ⓣ object in an ECMAScript implementation whose semantics are fully defined by this specification rather than by the host environment.

NOTE Standard native objects are defined in this specification. Some native objects are built-in; others may be constructed during the course of execution of an ECMAScript program.

4.3.7 built-in object # Ⓣ object supplied by an ECMAScript implementation, independent of the host environment, that is present at the start of the execution of an ECMAScript program.

NOTE Standard built-in objects are defined in this specification, and an ECMAScript implementation may specify and define others. Every built-in object is a native object. A built-in constructor is a built-in object that is also a constructor.

As you can see, it's different that what you've shown.

Built-in objects are native objects made available by the ECMAScript-compliant engine. For example:

  • String
  • Object
  • Array
  • Undefined
  • Boolean
  • etc.

A native object is, for example:

var obj = {};

Or the list shown before. Built-in objects are native.

Also, you didn't show it, but a host object is an object dependant on the environment. For example, in browsers, the host object is window. There are other host objects such as document or XMLHttpRequest though.

Florian Margaine
  • 58,730
  • 15
  • 91
  • 116
  • I think it's the other way around. The things you've listed as native objects are built-in, and an object created by a program is a native object. "built-in object... supplied by an ECMAScript *implementation*" – James Allardice Jul 24 '12 at 14:29
  • @JamesAllardice: A built-in object is also a native object. – Tim Down Jul 24 '12 at 14:31
  • @TimDown - Yes, but not the other way around, which is how I interpreted this answer originally. e.g. `String` is a built-in object (and therefore a native object). `var o = {};` is a native object, but not a built-in object. – James Allardice Jul 24 '12 at 14:33
  • `window` is not the only host object. It just happens also to be the global object, therefore containing properties referring to other host objects. – Tim Down Jul 24 '12 at 14:35
  • @TimDown I know, it's just a good example :) However I edited to please everyone! – Florian Margaine Jul 24 '12 at 14:37
  • Thanks for the answer Florian! I didn't mention host objects because there was another thread explaining the difference between native and host objects: http://stackoverflow.com/questions/7614317/what-is-the-difference-between-native-objects-and-host-objects – Leila Hamon Jul 24 '12 at 23:30
-3

Native object - means implemented not in ECMAScript itself. Buiilt-in object - the one that's provided by the engine. Think Math, String and such.

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
  • It's not provided by "the environment", it's provided by the ECMAScript engine. Environment in the ES specification means that environment the engine is running in, for example a browser. – Florian Margaine Jul 24 '12 at 14:36