0

I was learning from a course and i encountered this code :


if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position){
    const {latitude} = position.coords;
    const {longitude} = position.coords;
    console.log(lat,longitude);
    console.log(position);

  },
  function(){
    alert('could not get position');
  });
}

Can someone please explain me the meaning of this line of code ? const {latitude} = position.coords; and const {longitude} = position.coords; i would really appreciate an help.........

Please someone explain me the meaning of the line of code.

Het
  • 17
  • 4
  • [Destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) – Andy Dec 16 '22 at 08:59
  • [Object desctructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#object_destructuring) – Amila Senadheera Dec 16 '22 at 09:03

0 Answers0