main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Game {  
  constructor(name) {
    this.name = name;
  }

  getMessage() {
    return `I like ${this.name}!`;
  }
}

const doom = new Game('Doom');  

const doomFullClone = {  
  ...doom,
  __proto__: Game.prototype
};

console.log(doomFullClone instanceof Game) // => true  
console.log(doomFullClone.name);           // => "Doom"  
console.log(doomFullClone.getMessage());   // => "I like Doom!"  
Native Browser JavaScript