{}.length
throws in Chrome (and other browsers), while it returns undefined
in Node.
I know something like Object.keys({}).length
is the correct way to get the number of entries in an object, but I'm just more curious to understand why the browser API and the Node API are inconsistent here.
Maybe this has something to do with how parsing is performed? Both Chrome and Node use the V8 engine. My assumption was that this engine's parser is consistent between environments, but maybe it's not?
I wonder if it's intended, and has something to do with backwards compatibility, or unintended and might be rectified in the future.