SOURCE

const manyPolymorphism = () => {
  const saySting = (animals) => {
    animals.sound();
  };

  function Duck() {}
  Duck.prototype.sound = () => {
    console.log("gagaga");
  };

  function Chilcken() {}
  Chilcken.prototype.sound = () => {
    console.log("咯咯咯");
  };

  saySting(new Duck());
  saySting(new Chilcken());
};

manyPolymorphism();
console 命令行工具 X clear

                    
>
console