Skip to content

Instantly share code, notes, and snippets.

@devsnek

devsnek/js.js Secret

Created May 14, 2018 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devsnek/7e8d4a37c774819639088648ee9d1180 to your computer and use it in GitHub Desktop.
Save devsnek/7e8d4a37c774819639088648ee9d1180 to your computer and use it in GitHub Desktop.
class X extends Array {}
class Y extends X {}
Is(Array, new X()); // true
Is(X, new X()); // true
Is(Object, new X()); // true
Is(Map, new X()); // false
Is(Array, new Y()); // true
Is(X, new Y()); // true
Is(Y, new Y()); // true
Is(Object, new Y()); // true
Is(Map, new Y()); // false
const y = new Y();
Object.setPrototypeOf(y, null);
Is(Array, y); // true
Is(X, y); // true
Is(Y, y); // true
Is(Object, y); // true
Is(Map, y); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment