What is the difference between mongoose.Schema() and new mongoose.Schema()?
I used both the standards, and I think both do the same job. Does it affect in any way?
Looking at the docs, it should always be called with the new keyword, since Schema is a constructor.
Looking at the source code, it'll return a newly allocated object if you try to use it without the new keyword.
Both will work, but I would only use the first since it's the correct way. Following standard conventions will make your code easier to read; not only for others, but for you as well when you go back to it in 6 months.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With