.getDay()
Called from an instance of the Date
class, will return the day of the week.
Syntax
myDate.getDay();
The return value of getDay()
will only be an integer number between 0
and 6
:
0
meaning Sunday1
meaning Monday2
meaning Tueseday3
meaning Wednesday4
meaning Thursday5
meaning Friday6
meaning Saturday
Example
To determine if it is Friday or not:
const today = new Date('June 25, 2021 10:41:30');if (today.getDay() === 5) {console.log("It is Friday, let's have a coffee later!");} else {console.log('It is not Friday...');}// Output: It is Friday, let's have a coffee later!
Contributors
- Anonymous contributors