Why not work getDay?

I can not understand why does not work condition ((currentDate.getDay==1) || (currentDate.getDay==2)) in the script

$(function() {
 // get the date value from LocalStorage
 var dateModalShow = localStorage.getItem("dateModalShow");
 // get the current date
 var currentDate = new Date().toString();
 var period = (((new Date(currentDate)).getTime())- ((new Date(dateModalShow)).getTime()))/60000;
 // if the window is not displayed or since the last screening gone are the days and today is mon (or Tues), then
 if (((dateModalShow==null) || (period>1)) && ((currentDate.getDay==1) || (currentDate.getDay==2)) ) {
 // start a timer that will run the contents of the function after 5 minutes
setTimeout(function(){
$("#modal").modal('show');
 localStorage.setItem("dateModalShow", currentDate);
},60000);
}
});
July 4th 19 at 23:12
2 answers
July 4th 19 at 23:14
Solution
The string (!) currentDate trying to use a property (!) getDay.
more how to fix - Uriel.Schneid commented on July 4th 19 at 23:17
currentDate't call it a string.
In period, do not create from the string currentDate another object.
getDay is a method, not a property. - evie.Feil6 commented on July 4th 19 at 23:20
have been, even so does not work

$(function() {
// get the date value from LocalStorage
var dateModalShow = localStorage.getItem("dateModalShow");
// get the current date
var currentDate = new Date();
if ((currentDate.getDay==0) || (currentDate.getDay==1) || (currentDate.getDay==2) || (currentDate.getDay==3) || (currentDate.getDay==4) || (currentDate.getDay==5) || (currentDate.getDay==6) || (currentDate.getDay==7) ) {
// start a timer that will run the contents of the function after 5 minutes
setTimeout(function(){
$("#mailModal").modal('show');
localStorage.setItem("dateModalShow", currentDate);
},1);
}
}); - Uriel.Schneid commented on July 4th 19 at 23:23
And if after getDay add parentheses (like a function), you get. - evie.Feil6 commented on July 4th 19 at 23:26
came out, thank you - Uriel.Schneid commented on July 4th 19 at 23:29
: casinoice received and the number of the day, that he had not considered every time. - Jacinto22 commented on July 4th 19 at 23:32
July 4th 19 at 23:16
Solution
After that
var currentDate = new Date().toString();
currentDate contains a string with the date. Of course the row has no properties getDay.
Please note that when this next, you string with this date again, make a Date object.
And getDay is not a property, and the method, i.e. to cause it must be so currentDate.getDay()
"and kasiraja obtained the number of the day, that he had not considered every time. "

can you tell how, in js it is not strong - Uriel.Schneid commented on July 4th 19 at 23:19
: add var currentDay = currentDate.getDay(); And then in if'e do if ((currentDay===0) || (currentDay===1)......) - evie.Feil6 commented on July 4th 19 at 23:22

Find more questions by tags JavaScript