Skip to content

Instantly share code, notes, and snippets.

@blaja
Created August 8, 2015 13:41
Show Gist options
  • Select an option

  • Save blaja/af100b33d9b307e9e9bc to your computer and use it in GitHub Desktop.

Select an option

Save blaja/af100b33d9b307e9e9bc to your computer and use it in GitHub Desktop.

Revisions

  1. blaja created this gist Aug 8, 2015.
    18 changes: 18 additions & 0 deletions .js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    // NOTE: this is specification dependent classification. It has nothing to do with formal class programming concept.
    // The value of the [[Class]] internal property is defined by specification for every kind of built-in object.
    // The value of the [[Class]] internal property of a host object may be any String value except one of:
    // "Arguments", "Array", "Boolean", "Date", "Error", "Function", "JSON", "Math", "Number", "Object", "RegExp", and "String".
    // The value of a [[Class]] internal property is used internally to distinguish different kinds of objects.

    Object.prototype.toString.call({}); // "[object Object]"
    Object.prototype.toString.call([]); // "[object Array]"
    Object.prototype.toString.call(function(){}); // "[object Function]"
    Object.prototype.toString.call(''); // "[object String]"
    Object.prototype.toString.call(0); // "[object Number]"
    Object.prototype.toString.call(true); // "[object Boolean]"
    Object.prototype.toString.call(/''/); // "[object RegExp]"
    Object.prototype.toString.call(new Date); // "[object Date]"
    Object.prototype.toString.call(new Error); // "[object Error]"
    Object.prototype.toString.call(Math); // "[object Math]"
    Object.prototype.toString.call(JSON); // "[object JSON]"
    Object.prototype.toString.call(function(){return arguments;}()); // "[object Arguments]"