Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to add element to an object

const favoriteThings = {
  band: 'caravan palace',
  food: 'fried pickles',
}

//object notation
favoriteThings.car = 'my car'
//bracket notation 
favoriteThings['car'] = 'my car'
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #add #element #object
ADD COMMENT
Topic
Name
2+1 =