locked
JScript Active Scripting engine for ECMA-262 5th edition equality operator bug? RRS feed

  • Question

  • So I have a javascript function that tests the equality
    of String objects and string literals.
    Why is it I get different results using the == operator?
    When debugging with IE 11 browser the code below returns a 'false'
    for a testDate object for "7/4/2016".  However using Chrome
    returns true.

    function isHoliday(testDate) {
     //debugger;
     // check simple dates (month/date - no leading zeroes
     var n_date = testDate.getDay() + 1;
     let dayPart = 1; let monPart = 0; let yrPart = 2;
     let datePart = testDate.toLocaleDateString().split("/");
     var n_month = testDate.getMonth() + 1;
     var s_date1 = datePart[monPart] + '/' + datePart[dayPart];
     var NewYearsDay = "1/1";
     var IndependenceDay = "7/4";
     var VeteransDay = "11/11";
     var ChristmasDay = "12/25";
     //if (s_date1 == '1/1'   // New Year's Day
     //    || s_date1 == '7/4'   // Independence Day
     //    || s_date1 == '11/11' // Veterans Day
     //    || s_date1 == '12/25' // Christmas Day
     //) return true;
     //debugger;
     if (s_date1 == NewYearsDay   // New Year's Day
      || s_date1 == IndependenceDay   // Independence Day
      || s_date1 == VeteransDay // Veterans Day
      || s_date1 == ChristmasDay // Christmas Day
     ) return true;
    };

    Friday, June 17, 2016 1:58 PM

All replies

  • Hi CHILE_JSH,

    "So I have a javascript function that tests the equality of String objects and string literals."
    Based on your description, this issue seems to be more related to IE development.

    For IE development issue, it is suggested to contact to our IE development forum for suitable solution, they may have more resources to help you.
    https://social.msdn.microsoft.com/Forums/ie/en-US/home?forum=iewebdevelopment


    Best regards


    Please mark the reply as an answer if you find it is helpful.

    If you have feedback for TechNet Support, contact tnmff@microsoft.com

    Monday, June 20, 2016 6:32 AM