ts类定义和实例化

(function () {
    //
    var Person = /** @class */ (function () {
        function Person(name, age) {
            this.name = name;
            this.age = age;
        }
        return Person;
    }());
    function sayhi(p) {
        console.log(p.name + " | " + p.age);
    }
    //类的实例化是new,而接口是直接用json实例化
    var p = new Person('daye', 18);
    console.log(sayhi(p));
})();

 

posted @ 2024-07-24 22:19  关键步就几步  阅读(13)  评论(0编辑  收藏  举报