Klucz obiektu JavaScript Klawisz JavaScript

const animalSounds = {cat: 'meow', dog: 'bark'};

const animal = 'lion';

const sound = 'roar';

{...animalSounds, [animal]: sound};
zhiyuan zhang