Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does JavaScript have exotic objects?

I want to write a series of JavaScript related articles/tutorials. I was looking up the ECMA specification when I discovered this interesting paragraph.

As ECMA-262 (Version 6) states:

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.

Now I am curious. Are such exotic objects to be found in modern browser's JavaScript?

If so: Could one give me an example and tell in how far its behaviour is different from 'ordinary objects'?

like image 372
Tim Hallyburton Avatar asked Jul 29 '15 19:07

Tim Hallyburton


1 Answers

A possible example:

The instance objects created by Array are exotic (a term used by the ECMAScript specification for objects that have features that normal objects don’t have): Their property length tracks and influences the management of array elements. In general, exotic objects can be created from scratch, but you can’t convert an existing normal object into an exotic one.

Taken from http://www.2ality.com/2015/02/es6-classes-final.html

There's also a list later in the spec including Array, String, and so on.

They're not "exotic" in the sense of mysterious and/or sexy.

like image 141
Dave Newton Avatar answered Sep 21 '22 16:09

Dave Newton