Example would be:
const objectId = new mongoose.Types.ObjectId('id would go here');
if (_.isEmpty(objectId)) {
throw new Error('this throws an error');
}
ran code above and was just wondering if this is new, for what its worth, this code did not break before.
Using the following code:
You can see that
objectIdonly contains one property that whose key is aSymbol.You'll note that it isn't logged as a property (only
valueOfis logged), and that the keys array is empty.Looking at the source code you'll see it iterates over the keys using a for-in loop just as I did to log the properties.
Since we have no properties to log that satisfies
hasOwnProperty, then the loop ends and it returnstrue.