function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
var output = [];
for (var i = 0, l = value.length; i < l; ++i) {
- if (Object.prototype.hasOwnProperty.call(value, String(i))) {
+ if (hasOwnProperty(value, String(i))) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
String(i), true));
} else {
str = ctx.stylize('[Setter]', 'special');
}
}
- if (!visibleKeys.hasOwnProperty(key)) {
+ if (!hasOwnProperty(visibleKeys, key)) {
name = '[' + key + ']';
}
if (!str) {
}
return origin;
};
+
+function hasOwnProperty(obj, prop) {
+ return Object.prototype.hasOwnProperty.call(obj, prop);
+}
// GH-2225
var x = { inspect: util.inspect };
assert.ok(util.inspect(x).indexOf('inspect') != -1);
+
+// an object with "hasOwnProperty" overwritten should not throw
+assert.doesNotThrow(function() {
+ util.inspect({
+ hasOwnProperty: null
+ });
+});