Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Why do I need "new" before "Date" to declare the variable?

this js code is run in 31/2/2022

var today = new Date();
console.log(today);
var start = Date(2021, 5, 30);
console.log(start);

however, when I open the console, it showed both day are the current time, 31/5/2022 8PM, ....

But when I add new before

var today = new Date();
console.log(today);
var start = new Date(2021, 5, 30);
console.log(start);

it works.

Why did this happen?

Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!