title: jQuery find closest location to those in an object
body: <p>I'm building a mobile app, and one area I'm not quite sure how to tackle is the facility to find the closest location in the locations object to the user's current location.</p>
  
  <p>For example, when a user taps 'Find nearest', their long and lat is stored as variables. I have an object that has data for locations the app can use in this structure:</p>
  
  <pre><code>locations
  -123
  --Name: Llandudno
  --Long: 12345
  --Lat: -23455
  -124
  --Name: Conwy
  --Long: 12347
  --Lat: -23459
  </code></pre>
  
  <p>How can I (using jQuery) find which location is closest to the user, or can this not be done using some form of mathematical equation? If so, what does anyone recommend?</p>
  
  <p>Thanks in advance for your help</p>