Skip to content

Instantly share code, notes, and snippets.

@fredyang
Created October 29, 2012 01:39
Show Gist options
  • Save fredyang/3970911 to your computer and use it in GitHub Desktop.
Save fredyang/3970911 to your computer and use it in GitHub Desktop.
fool around the operator "intanceof"
var A = function () {};
var B = function () {};
//begin_trick
//---the following will make " (new B()) instanceof A " return true
(function () {
var T = function () {};
T.prototype = A.prototype;
B.prototype = new T();
})();
//end_trick
(new B()) instanceof A;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment