Skip to content

Commit

Permalink
Not all Objects have a constructor property
Browse files Browse the repository at this point in the history
Reviewed By: avp

Differential Revision: D18284972

fbshipit-source-id: a3e65654df24a7b2197913c27516a128275962ef
  • Loading branch information
mhorowitz authored and facebook-github-bot committed Nov 14, 2019
1 parent 98737a8 commit d46809b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/repl/pretty.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ obj[Symbol('xyz')] = 5
obj
// CHECK-NEXT: { Symbol(abc): 3, Symbol(def): 4, Symbol(xyz): 5 }

obj = Object.create(null)
// CHECK-NEXT: { }

a = {}
// CHECK-NEXT: { }
Object.defineProperty(a, 'x', {
Expand Down
2 changes: 1 addition & 1 deletion tools/repl/evaluate-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ C_STRING((function() {
elements.push(prettyPrintProp(value, prop, visited));
}
}
if (value.constructor.name && value.constructor.name !== "Object") {
if (value.constructor && value.constructor.name && value.constructor.name !== "Object") {
return value.constructor.name + ' { ' + elements.join(', ') + ' }';
} else {
return '{ ' + elements.join(', ') + ' }';
Expand Down

0 comments on commit d46809b

Please sign in to comment.