title: How to de-structure an enum values in typescript?
body: <p>I have an enum in typescript like below:</p>
  <pre class="lang-js prettyprint-override"><code>export enum XMPPElementName {
    state = &quot;state&quot;,
    presence = &quot;presence&quot;,
    iq = &quot;iq&quot;,
    unreadCount = &quot;uc&quot;,
    otherUserUnreadCount = &quot;ouc&quot;,
    sequenceID = &quot;si&quot;,
    lastSequenceID = &quot;lsi&quot;,
    timeStamp = &quot;t&quot;,
    body = &quot;body&quot;,
    message = &quot;message&quot;
  }
  </code></pre>
  <p>And wants to de-structure its value, How can we do this in Typescript?</p>
  <pre><code>const { uc, ouc, msg, lsi, si, t, body } =  XMPPElementName; 
  </code></pre>
  <h1>update</h1>
  <p>As @amadan <a href="https://stackoverflow.com/a/64548582/12666332">mentioned</a>, we can use <code>Assigning to new variable names</code> as in Mozilla doc say <a href="https://stackoverflow.com/a/64548439/12666332">Destructuring_assignment</a>, like below:</p>
  <h3>Assigning to new variable names</h3>
  <p>A property can be unpacked from an object and assigned to a variable with a different name than the object property.</p>
  <pre class="lang-js prettyprint-override"><code>const o = {p: 42, q: true};
  const {p: foo, q: bar} = o;
   
  console.log(foo); // 42 
  console.log(bar); // true
  </code></pre>
  <p>And the method is very good to solve this problem, but if  you need to access all items without the need to explicitly define them, you can either on of these two mentiond <a href="https://stackoverflow.com/a/64548582/12666332">tag1</a> <a href="https://stackoverflow.com/a/64548439/12666332">tag2</a></p>