Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Date prototype getDay return error

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #269840
    Pranab
    Participant

    I tried in the console Date.prototype.getDay and it return the correct getDay function. but after doing this Date.prototype.getDay(), it return error.
    Error is “Uncaught TypeError: this is not a Date object.”
    Why it’s giving error?

    #269845
    Xiija
    Participant
     var time = new Date();
     var wkday = [0,"sun",1,"mon",2,"tues",3,"wed",4,"thurs",5,"fri",6,"sat"]
     var check = time.getDay();
     console.log ( "today is " + wkday[check + 1] );
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.