What would be the output? [Object Destructuring]

@Yomesh Gupta

Let say we have a variable state which represents our current application state.

const state = {
  user: {
    id: null,
    name: '', // empty string
    subscribe: false,
    link: '', // empty string
  },
};

We want to destructure user information.

function getUser() {
  const {
    user: {
      id = 1,
      name = 'Devtools Tech',
      subscribe = true,
      link = 'https://bit.ly/devtools-yt',
    } = {},
  } = state;

  return {
    userId: id,
    name,
    subscribe,
    link,
  };
}

Now, what would be the output if we call getUser function.

console.log(getUser());
Option 1
{
  "userId": 1,
  "name": "Devtools Tech",
  "subscribe": true,
  "link": "https://bit.ly/devtools-yt"
}
Option 2
{
  "userId": null,
  "name": "",
  "subscribe": false,
  "link": ""
}
Option 3
{
  "userId": 1,
  "name": "Devtools Tech",
  "subscribe": false,
  "link": "https://bit.ly/devtools-yt"
}
Option 4
{
  "userId": 1,
  "name": "",
  "subscribe": true,
  "link": ""
}