We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
@@toStringTag
Object#toString
1 parent 35cbff7 commit c03afceCopy full SHA for c03afce
index.js
@@ -1,12 +1,20 @@
1
'use strict';
2
3
var getDay = Date.prototype.getDay;
4
-
5
-module.exports = function isDateObject(value) {
+var tryDateObject = function tryDateObject(value) {
6
try {
7
getDay.call(value);
8
return true;
9
} catch (e) {
10
return false;
11
}
12
};
+
13
+var toStr = Object.prototype.toString;
14
+var dateClass = '[object Date]';
15
+var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
16
17
+module.exports = function isDateObject(value) {
18
+ if (typeof value !== 'object' || value === null) { return false; }
19
+ return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
20
+};
0 commit comments