127k views
1 vote
Which of the following statements is NOT a valid way to create a date object named birthday?

var birthday = "12/2/1978";

var birthday = new Date();

var birthday = new Date("12/2/1978");

var birthday = new Date(1978, 11, 2);

User Mkb
by
5.4k points

1 Answer

5 votes

Answer:

var birthday = "12/2/1978";

Step-by-step explanation:

It does not create a date object named birthday because in this statement the birthday is a string which contains 12/2/1978 a date it is not date object it is a string.All other three options are correct way to create a date object.

var birthday = new Date();

creates a date object with the current date and time.

we can also pass date string in the new Date().So var birthday = new Date("12/2/1978"); is also correct.

we can also pass year,month,day in new Date() In this order only.So option fourth is also correct.

User Justin Lucas
by
5.0k points