Skip to content

Commit c23c523

Browse files
committed
Optimized for number first quick escape.
1 parent 8f42250 commit c23c523

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

v3/src/utils/object/GetValue.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44

55
var GetValue = function (source, key, defaultValue)
66
{
7-
if (!source)
7+
if (!source || typeof source === 'number')
88
{
99
return defaultValue;
1010
}
11+
else if (source.hasOwnProperty(key))
12+
{
13+
return source[key];
14+
}
1115
else if (key.indexOf('.'))
1216
{
1317
var keys = key.split('.');
@@ -36,7 +40,7 @@ var GetValue = function (source, key, defaultValue)
3640
}
3741
else
3842
{
39-
return (source.hasOwnProperty(key)) ? source[key] : defaultValue;
43+
return defaultValue;
4044
}
4145
};
4246

0 commit comments

Comments
 (0)