mirror of https://github.com/nodejs/node.git
util: isObject should always return boolean
Fix small bug where isObject would return the original object instead of true.pull/28770/head
parent
edd2fcccf0
commit
50cee6ecab
|
@ -486,7 +486,7 @@ function isRegExp(re) {
|
|||
exports.isRegExp = isRegExp;
|
||||
|
||||
function isObject(arg) {
|
||||
return typeof arg === 'object' && arg;
|
||||
return typeof arg === 'object' && arg !== null;
|
||||
}
|
||||
exports.isObject = isObject;
|
||||
|
||||
|
|
|
@ -70,6 +70,9 @@ assert.equal(false, util.isError({ name: 'Error', message: '' }));
|
|||
assert.equal(false, util.isError([]));
|
||||
assert.equal(false, util.isError(Object.create(Error.prototype)));
|
||||
|
||||
// isObject
|
||||
assert.ok(util.isObject({}) === true);
|
||||
|
||||
// _extend
|
||||
assert.deepEqual(util._extend({a:1}), {a:1});
|
||||
assert.deepEqual(util._extend({a:1}, []), {a:1});
|
||||
|
|
Loading…
Reference in New Issue