I heard somewhere that new keyword is not mandatory everywhere. Is that true?
app.post('/tasks', (req, res) => {
const task = new Task(req.body)
here if i dnt write new, its still working. I am confuse about this keyword
validate(value) {
if(value.toLowerCase().includes('password')) {
throw new Error(`Password can't be "password"`)
}
}
const add = (a, b) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(a + b)
}, 2000)
})
}
Again here if i dnt give new ,its not working. Can someone elaborate the difference?