why do I need to use the keyword new when using Date().
var currentDate = new Date();
console.log(currentDate);
but if i just do the below I can still get the date.
console.log(Date());
why do I need to use the keyword new when using Date().
var currentDate = new Date();
console.log(currentDate);
but if i just do the below I can still get the date.
console.log(Date());
The new keyword does the following things:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new