ぶれすとつーる

だいたいjavascript

exotic objectがhost objectの呼び名が変わったものという風潮

  • native object -> ordinary object
  • host object -> exotic object

って感じの解釈をよく聞くけど違うと思う。(誰も言ってなかったらごめんなさい)

es6上での定義

4.3.6 ordinary object

object that has the default behaviour for the essential internal methods that must be supported by all objects.

4.3.7 exotic object

object that does not have the default behaviour for one or more of the essential internal methods that must be supported by all objects.

NOTE Any object that is not an ordinary object is an exotic object.

http://people.mozilla.org/~jorendorff/es6-draft.html#sec-ordinary-object

全てのオブジェクトが持ってる必須な内部メソッドの振る舞いがデフォルトなやつがordinary object

それ以外(内部メソッドの振る舞いがデフォルトじゃないやつ)がexotic object

ってなってるはず。

es5.1の定義

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.8 host object

object supplied by the host environment to complete the execution environment of ECMAScript

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

http://www.ecma-international.org/ecma-262/5.1/#sec-4.3.6

となっていて実行環境ごとに作られるのがhost objectで、そうでないesによって実装されてるのがnative object.

なので

たとえばArrayとかはES5の定義ではnative objectだと思うんだけど、ES6の定義では[[DefineOwnProperty]]lengthを考慮するように変更されててデフォルトの振る舞いと違うのでexotic objectになる

http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array-exotic-objects

An Array object is an exotic object