You can also use the
Date object to
get the number of the current day of the
week. This is done using the
method. This method returns numbers from
6, where week starts
on Sunday and this day is numbered
0. Monday is day number
Tuesday is day number
2, and so on.
Let's see how the
works with an example. Let's say today
is Tuesday. Then the following code
will output the number
let date = new Date(); console.log(date.getDay());
Display the number of the current day of the week.
Determine if the current day of the week is a weekend or a workday.
Find out how many days are left until next Sunday.