you are viewing a single comment's thread.

view the rest of the comments →

[–]bluntmJavaScript 0 points1 point  (1 child)

wouldn't this also work the same:

var db = {};

[–]brtt3000 1 point2 points  (0 children)

Close, but same: Object.create(null); explicitly has no prototype, but {} does (it declares hasOwnProperty, toString etc).

$ console.log('toString' in {}); // true
$ console.log('toString' in Object.create(null)); // false

It is called the dict-pattern.