title: Stopping the Jquery.map when a condition is met
body: <p>I have the following code:</p>
  
  <pre><code>var parentEls = node.parents() 
      .map(function () {
  
          var curParentID = this.getAttribute("id"); 
          var curParentClass = this.getAttribute("class");
  
          if(curParentID) {
              return this.tagName + "#" + curParentID;
              /*stop the map function from proceeding*/
          } else {
              return this.tagName;
          }
      })
      .get().reverse().join(", ");
  </code></pre>
  
  <p>The above code helps to find search for unique id and once an ID is spotted , it creates the xpath. How can i stop the the map function once it has come to a point where the id is retrieved and the map function should stop? I tried return false and break but it does not work.</p>
  
  <p>Is there any other suggestion?</p>