title: How to tell if two cells are equal in Google Apps Script for Google Spreadsheet
body: <p>I am writing a script to bind two cells to always hold the same value after every edit. My script so far looks like this:</p>
  
  <pre><code>function myEdit(event){
    var ss = event.source.getActiveSheet();
    var r = event.source.getActiveRange();
    var bind1 = ss.getRange("D11:D11").getCell(1,1);
    var bind2 = ss.getRange("D10:D10").getCell(1,1);
    var editedCell = r.getCell(1,1);
  
    Logger.log("checking");
    if (editedCell === bind1){
      Logger.log("Condition was Met!");
      bind1.copyTo(bind2);
    }
    else if (editedCell === bind2){
      Logger.log("Condition was met!");
      bind2.copyTo(bind1);
    }
    else{
      Logger.log("No condition was met.");
    }
  </code></pre>
  
  <p>When I change the value in either of the bound cells, nothing is copied anywhere else. When I check the execution logs, it appears everything went fine</p>
  
  <pre><code>[14-07-21 10:47:06:215 EDT] Execution succeeded [0.884 seconds total runtime]
  </code></pre>
  
  <p>But when I check the Logger logs, I get </p>
  
  <pre><code>[14-07-21 10:55:49:260 EDT] checking
  [14-07-21 10:55:49:260 EDT] No condition was met.
  </code></pre>
  
  <p>For some reason, the program is not recognizing that editedCell and bind1 are the same object, when I edit cell D11. </p>
  
  <p>By checking the values of bind1 and editedCell, the values are the same so they must be referring to the same cell, but the equality operator is not working to check whether they are the same range.</p>