Below is the example of Date getDay() method.
Number of Day: 2
The date.getDay() method is used to fetch the day of a week(0 to 6) from a given Date object.
Parameter: This method does not accept any parameters.
Return Values: It returns the day of the week for the given date. Day of the week will be returned in the form of integer value ranging from 0 to 6 means 0 for Sunday, 1 for Monday, and so on till 6 for Saturday.
More codes for the above method are as follows:
Program 1: If the date of the month is not given, by default the function considers it as the first date of the month and hence accordingly it returns the day of the week. It is an exceptional case.
Number of Day: 1
Program 2: The date of the month should must lie in between 1 to 31 because none of the month have date greater than 31 that is why it returns NaN i.e, not a number because date for the month does not exist.
Program 3: If nothing as parameter is given, it returns current day of the current week.
- Google Chrome 1 and above
- Edge 12 and above
- Firefox 1 and above
- Internet Explorer 3 and above
- Opera 3 and above
- Safari 1 and above