How does the ISO date look in JavaScript? What will be logged to the console?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
In the first line, we create a new Date
object.
It holds the current date and time.
The function toISOString
returns the string representation of the date
object in the ISO
format. It starts with the year and ends with time. Something like 2020-12-27T10:35:26.159Z
.
When we’re slicing this string with slice(0, 4)
we’ll get the first four characters, which represent the year.
ANSWER: the current year will be logged to the console.
Top comments (0)