This article describes the method of JavaScript to get the current date of the week. Share it for your reference. The details are as follows:
JavaScript gets the current date of the week, and it mainly uses the getDay function to get what day of the week
<!DOCTYPE html> <html> <body> <p > Click the button to display todays day of the week. </p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var d = new Date(); var weekday=new Array(7); weekday[0]="Sunday"; weekday[1]="Monday"; weekday[2]="Tuesday"; weekday[3]="Wednesday"; weekday[4]="Thursday"; weekday[5]="Friday"; weekday[6]="Saturday"; var x = ("demo"); =weekday[()]; } </script> </body> </html>
I hope this article will be helpful to everyone's JavaScript programming.