How to create an object that inherit allthe properties of other object in JavaScript

1 Answer

0 votes
const user = {
  id: 928737,
  name: 'Rose'
};

const worker = Object.create(user, {
  city: {
    value: 'new york'
  }
});

console.log(worker.id); 
console.log(worker.name); 
console.log(worker.city); 



/*
run:
  
928737 
Rose 
new york
​   
*/

 



answered Nov 8, 2019 by avibootz
...