diff --git a/lib/util.js b/lib/util.js index 5addac5c3aa..78c16a51204 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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; diff --git a/test/simple/test-util.js b/test/simple/test-util.js index 7c30f5e83e5..2acdbdb0cac 100644 --- a/test/simple/test-util.js +++ b/test/simple/test-util.js @@ -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});