Microsoft
98-382 · Question #18
You are creating JavaScript code that manipulates dates. You want to initialize a Date object with the date January 1, 2017 by using the year, month, and date parameters. How should you complete the…
To initialize a Date object with January 1, 2017 using the year, month, and date parameters, the correct code is: ``javascript var date = new Date(2017, 0, 1); `` (Note: In JavaScript's Date constructor, months are 0-indexed, so January is represented by 0.)
Variables, Data Types, and Functions
Question
You are creating JavaScript code that manipulates dates. You want to initialize a Date object with the date January 1, 2017 by using the year, month, and date parameters. How should you complete the code? To answer, select the appropriate code segment in the answer area.
Explanation
To initialize a Date object with January 1, 2017 using the year, month, and date parameters, the correct code is:
var date = new Date(2017, 0, 1);
(Note: In JavaScript's Date constructor, months are 0-indexed, so January is represented by 0.)
Topics
#Date object#constructor#initialization#parameters
Community Discussion
No community discussion yet for this question.