title: How to parse/compare moment objects in react?
body: <p>I have a component that sets the startDate and endDate based on various selectors in the dropdown the user may choose.<br>
  Code looks like so:<br></p>
  <pre><code>  const handleDateOptionChange = option =&gt; {
      if (option?.value === &quot;day&quot;) {
        setStartDate(moment().startOf(&quot;day&quot;));
        setEndDate(moment());
      }
  
      if (option?.value === &quot;week&quot;) {
        setStartDate(moment().startOf(&quot;week&quot;));
        setEndDate(moment());
      }
  
      if (option?.value === &quot;month&quot;) {
        setStartDate(moment().startOf(&quot;month&quot;));
        setEndDate(moment());
      }
  
  ...
  
      setDateOption(option);
    };
  </code></pre>
  <p>For my purposes, I'm trying to compare the startDate and endDate's values to moment() objects so that I can find a way to keep the correct selector in the dropdown selected on a page refresh (I'm grabbing start and endDate from queryParams).</p>
  <p>I have a piece of code to test this out that looks like so:</p>
  <pre><code> const setDateOption = () =&gt; {
      console.log(startDate);
      console.log(moment().startOf(&quot;day&quot;));
      if (startDate == moment().startOf(&quot;day&quot;) &amp;&amp; endDate == moment()) {
        return dateOptions[0];
      }
      return dateOptions[1];
    };
  </code></pre>
  <p>Obviously I'm learning I cannot compare them that way. The output of those respective objects are as follows:<br>
  <a href="https://i.stack.imgur.com/gpHro.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gpHro.png" alt="logs" /></a></p>
  <p>The _d portions of the moment object match, but I've been told to not use those for comparisons. How might I compare my startDate with an actual moment() type object?</p>