+ 1
I have found a javascript code which s quite strange to me... can someone explain it to me?
In javascript world i have found a code var nextDate = new Date().getMonth()+1; var year = new Date().getFullYear(); var nextDate = new Date(nextMonth +' 1 ,'+year); I can not understand the code on the 3rd line can someone explain this to me? Thanking you.
1 ответ
+ 1
1. Logging results and commenting
https://code.sololearn.com/WqEsJ6bP48gm/?ref=app
p. s. you have a typo with the first var name
2. Explanation
When new Date object is created,
it accepts an optional argument,
a date string,
if it is 8 1, 2019
the date instance created is August 1st, 2019.
3. Demo date string
https://code.sololearn.com/Wbcq916W43CI/?ref=app
4. Reference MDN :
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date