That’s actually good design. Objects by default inherit the Object.prototype
that contains some helper functions (.toString()
, .valueOf()
). Now if you use req.body
and you pass no parameters to the HTTP request, then you'd expect req.body
to be empty. If it were just "a regular object", it wouldn't be entirely empty:
console.info(({ "toString": 5 })['toString']); // 5
console.info(({})['toString']); // [Function: toString]
There is a way to create "empty objects", meaning objects without any properties / prototype, and that is Object.create(null)
. You are seeing one of those objects in the console.
So no, this is not a bug that needs to be fixed, that’s just great use of JS' features.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…