Skip to content

Commit f519fff

Browse files
committed
Merge branch 'master' of github.com:DABH/array-typeof-values
2 parents 5d2ed80 + 5c4e32e commit f519fff

1 file changed

Lines changed: 15 additions & 19 deletions

File tree

index.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,23 @@ module.exports = function arrayTypeOfValues(array) {
1313
return undefined;
1414
}
1515

16-
var types = [];
17-
18-
array.map(
16+
var types = array.map(
1917
function(value)
2018
{
21-
if (typeof value === 'undefined')
22-
{
23-
types.push('undefined');
24-
}
25-
else if (value.constructor === Array)
26-
{
27-
types.push('array');
28-
}
29-
else if (typeof value === 'object')
30-
{
31-
types.push(value === null ? 'null' : 'object');
32-
}
33-
else
34-
{
35-
types.push(typeof value);
36-
}
19+
if (typeof value === 'undefined')
20+
{
21+
return 'undefined';
22+
}
23+
if (value.constructor === Array)
24+
{
25+
return 'array';
26+
}
27+
if (typeof value === 'object')
28+
{
29+
return value === null ? 'null' : 'object';
30+
}
31+
32+
return typeof value;
3733
}
3834
);
3935

0 commit comments

Comments
 (0)