“Zerstörungen in ES6” Code-Antworten

Objekt zerstören

const book = {
    title: 'Ego is the Enemy',
    author: 'Ryan Holiday',
    publisher: {
        name: 'Penguin',
        type: 'private'
    }
};

const {title: bookName =  'Ego', author, name: {publisher: { name }} = book, type: {publisher: { type }} = book } = book;
Scary Snail

Objekt zerstören

Object Destructuring =>
//
   The destructuring assignment syntax is a JavaScript expression that makes it
possible to unpack values from arrays,
or properties from objects, into distinct variables.
//
example:
const user = {
    id: 42,
    is_verified: true
};

const {id, is_verified} = user;

console.log(id); // 42
console.log(is_verified); // true 
kepl3r

Beispiel für das Zerstören von Objekten

const hero = {
  name: 'Batman',
  realName: 'Bruce Wayne',
  address: {
    city: 'Gotham'
  }
};

// Object destructuring:
const { realName, address: { city } } = hero;
city; // => 'Gotham'
Nutty Narwhal

Zerstörungen in ES6

let {a, b, c} = obj
Outrageous Ostrich

Zerstörungen in ES6

var a = obj.a
var b = obj.b
var c = obj.c
Outrageous Ostrich

Objekt zerstören in JavaScript

const hero = {
  name: 'Batman'
};
// Object destructuring:
const { name: heroName } = hero;
heroName; // => 'Batman'
Dangerous Dunlin

Ähnliche Antworten wie “Zerstörungen in ES6”

Fragen ähnlich wie “Zerstörungen in ES6”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen