In a function I have the line:
const currentTime = new Date.getTime();
The code compiles just fine.
Also, ESLint displays neither warnings or
errors.
But when I run the code, I get an alert box giving the confusing
message Date.getTime is not a constructor
.
What is wrong here?
I have noticed that there is no error if I don’t call the function
that contains the line above.
The following Stack Snippet reproduces the error.
function rightNow() {
const currentTime = new Date.getTime();
return currentTime;
}
console.log(rightNow().toString());
// ^^ No error if I comment out the previous line! ^^
.as-console-wrapper { max-height: 100% !important; top: 0; }