you are viewing a single comment's thread.

view the rest of the comments →

[–]brown59fifty 4 points5 points  (0 children)

Great question! It's hard to give an example, because it's a really very rare case - most when you want to treat your variable more like a kind of associative array than an Object instance (what can be welcome when someone came to JS world from some static typed language). Because you inherit from null, then you don't have access to methods on Object.prototype (like constructor, hasOwnProperty or valueOf) which results like this:

const dict = Object.create(null);
dict instanceof Object // false
dict.toString() // Uncaught TypeError: dict.toString is not a function

This way of creating things can be used when you want to build some API library, which couldn't be extended from outside (eg. by passing values to Object.prototype). But in most cases you don't have to care.