Last active
February 13, 2016 22:36
-
-
Save jjsub/fc72631ffe7bb1d1c48d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Type () {} | |
var types = [ | |
new Array(), | |
[], | |
new Boolean(), | |
true, // remains unchanged | |
new Date(), | |
new Error(), | |
new Function(), | |
function () {}, | |
Math, | |
new Number(), | |
1, // remains unchanged | |
new Object(), | |
{}, | |
new RegExp(), | |
/(?:)/, | |
new String(), | |
'test' // remains unchanged | |
]; | |
for (var i = 0; i < types.length; i++) { | |
types[i].constructor = Type; | |
types[i] = [types[i].constructor, types[i] instanceof Type, types[i].toString()]; | |
} | |
console.log(types.join('\n')); | |
function Type() {},false, | |
function Type() {},false, | |
function Type() {},false,false | |
function Boolean() { | |
[native code] | |
},false,true | |
function Type() {},false,Mon Sep 01 2014 16:03:49 GMT+0600 | |
function Type() {},false,Error | |
function Type() {},false,function anonymous() { | |
} | |
function Type() {},false,function () {} | |
function Type() {},false,[object Math] | |
function Type() {},false,0 | |
function Number() { | |
[native code] | |
},false,1 | |
function Type() {},false,[object Object] | |
function Type() {},false,[object Object] | |
function Type() {},false,/(?:)/ | |
function Type() {},false,/(?:)/ | |
function Type() {},false, | |
function String() { | |
[native code] | |
},false,test | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment