Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Square Brackets Javascript Object Key

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

const animal = 'lion';

const sound = 'roar';

{...animalSounds, [animal]: sound};
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Square #Brackets #Javascript #Object #Key
ADD COMMENT
Topic
Name
5+9 =