JSFiddle - React, Tailwind, and code Playground

by Federico

JavaScript

const person = {
  // name: 'Federico',
  age: 41,
  location: {
    city: 'Rome',
    temp: 11
  }
};

const { name: firstName = 'Anonymous', age } = person;
console.log(`${firstName} is ${age}.`);

const { city, temp: temperature } = person.location;
if (city && temperature) {
  console.log(`It's ${temperature} in ${city}`);
}

const book = {
  title: 'It',
  author: 'Stephen King',
  publisher: {
    // name: 'Penguin'
  }
}

const { name: publisherName = 'self-published' } = book.publisher;
console.log(publisherName);