How to add properties to an object in Node.js

1 Answer

0 votes
const obj = { Name: "Tim" };
console.log(obj);

obj.Age = 38;
console.log(obj);

obj.Country = "AU";
console.log(obj);
 
  
 
 
  
     
/*
run:
           
{ Name: 'Tim' }
{ Name: 'Tim', Age: 38 }
{ Name: 'Tim', Age: 38, Country: 'AU' }
         
*/

 



answered Feb 25, 2022 by avibootz

Related questions

3 answers 115 views
1 answer 111 views
1 answer 110 views
1 answer 127 views
1 answer 116 views
1 answer 94 views
2 answers 266 views
...