asked 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);

asked
User Mkb
by
8.3k 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.

answered
User Justin Lucas
by
7.4k points

No related questions found

Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.