-
-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathindex.js
128 lines (88 loc) · 2.97 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
'use strict';
var hasMapSupport = require( '@stdlib/utils/detect-map-support' )();
var hasSymbolSupport = require( '@stdlib/utils/detect-symbol-support' )();
var constructorName = require( './../lib' );
console.log( constructorName( 'a' ) );
// returns 'String'
console.log( constructorName( 5 ) );
// returns 'Number'
console.log( constructorName( NaN ) );
// returns 'Number'
console.log( constructorName( null ) );
// returns 'Null'
console.log( constructorName( undefined ) );
// returns 'Undefined'
console.log( constructorName( true ) );
// returns 'Boolean'
console.log( constructorName( false ) );
// returns 'Boolean'
console.log( constructorName( {} ) );
// returns 'Object'
console.log( constructorName( [] ) );
// returns 'Array'
console.log( constructorName( function noop(){} ) );
// returns 'Function'
console.log( constructorName( /./ ) );
// returns 'RegExp'
console.log( constructorName( new Date() ) );
// returns 'Date'
if ( hasMapSupport ) {
console.log( constructorName( new Map() ) );
// returns 'Map'
}
console.log( constructorName( new WeakMap() ) );
// returns 'WeakMap'
console.log( constructorName( new Set() ) );
// returns 'Set'
console.log( constructorName( new WeakSet() ) );
// returns 'WeakSet'
if ( hasSymbolSupport ) {
console.log( constructorName( Symbol() ) );
// returns 'Symbol'
}
console.log( constructorName( new Error() ) );
// returns 'Error'
console.log( constructorName( new TypeError() ) );
// returns 'TypeError'
console.log( constructorName( new SyntaxError() ) );
// returns 'SyntaxError'
console.log( constructorName( new URIError() ) );
// returns 'URIError'
console.log( constructorName( new RangeError() ) );
// returns 'RangeError'
console.log( constructorName( new ReferenceError() ) );
// returns 'ReferenceError'
console.log( constructorName( new EvalError() ) );
// returns 'EvalError'
console.log( constructorName( new Int8Array() ) );
// returns 'Int8Array'
console.log( constructorName( new Uint8Array() ) );
// returns 'Uint8Array'
console.log( constructorName( new Uint8ClampedArray() ) );
// returns 'Uint8ClampedArray'
console.log( constructorName( new Int16Array() ) );
// returns 'Int16Array'
console.log( constructorName( new Uint16Array() ) );
// returns 'Uint16Array'
console.log( constructorName( new Int32Array() ) );
// returns 'Int32Array'
console.log( constructorName( new Uint32Array() ) );
// returns 'Uint32Array'
console.log( constructorName( new Float32Array() ) );
// returns 'Float32Array'
console.log( constructorName( new Float64Array() ) );
// returns 'Float64Array'
console.log( constructorName( new ArrayBuffer() ) );
// returns 'ArrayBuffer'
console.log( constructorName( new Buffer( 'beep' ) ) );
// returns 'Buffer'
console.log( constructorName( Math ) );
// returns 'Math'
console.log( constructorName( JSON ) );
// returns 'JSON'
function Person(){}
console.log( constructorName( new Person() ) );
// returns 'Person'
var Person = function(){};
console.log( constructorName( new Person() ) );
// returns ''