Skip to content

JavaScript destructuring rename

  • by

If you want to destructure it change the names then take the same property for restructuring. You can rename one of the fields using this syntax:

const { old_firstName: new_name, lastName } = object

You can assign new variable names like shown in this MDN Example

var o = { p: 42, q: true };

// Assign new variable names
var { p: foo, q: bar } = o;

console.log(foo); // 42
console.log(bar); // true  

JavaScript destructuring rename

Simple example code.

<!DOCTYPE html>
    const person = {
      f: 'Tom',
      l: 'Hank'

    const { f: name, l } = person



JavaScript destructuring rename

One more example twitter property to call it tweet. And facebook property to call it fb.

    const twitter = '';
    const wes = {
      first: 'Tutorial',
      last: 'EyeHunts',
      links: {
        social: {
          twitter: '',
          facebook: '',
        web: {
          blog: ''
    const { twitter: tweet, facebook: fb } =;


Do comment if you have any doubts or suggestions on this Js destructuring topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *