15.多态

2019-06-06  本文已影响0人  Fl_来看看

1.什么是强类型语言, 什么是是弱类型语言

1.3由于js语言是弱类型的语言, 所以我们不用关注多态

2.什么是多态?

        function Dog() {
            this.eat = function () {
                console.log(" 狗吃东西");
            }
        }

        function Cat() {
            this.eat = function () {
                console.log(" 猫吃东西");
            }
        }

        function feed(animal){
            animal.eat();
        }
        let dog = new Dog();
        feed(dog);

        let cat = new Cat();
        feed(cat);
上一篇下一篇

猜你喜欢

热点阅读