Skip to content

Commit 4356927

Browse files
committed
use once Object.prototype.toString.call
1 parent e8e9fa2 commit 4356927

File tree

1 file changed

+7
-6
lines changed
  • packages/react-devtools-shared/src

1 file changed

+7
-6
lines changed

packages/react-devtools-shared/src/utils.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,13 @@ export function getDataType(data: Object): DataType {
439439
return 'iterator';
440440
} else if (data.constructor && data.constructor.name === 'RegExp') {
441441
return 'regexp';
442-
} else if (Object.prototype.toString.call(data) === '[object Date]') {
443-
return 'date';
444-
} else if (
445-
Object.prototype.toString.call(data) === '[object HTMLAllCollection]'
446-
) {
447-
return 'html_all_collection';
442+
} else {
443+
const toStringValue = Object.prototype.toString.call(data);
444+
if (toStringValue === '[object Date]') {
445+
return 'date';
446+
} else if (toStringValue === '[object HTMLAllCollection]') {
447+
return 'html_all_collection';
448+
}
448449
}
449450
return 'object';
450451
case 'string':

0 commit comments

Comments
 (0)