/** * 构造一个动物的函数 */function Animal(name, color){ this.name = name; this.color = color; this.getName = function(){ return this.name; }}// 实例一个对象var cat = new Animal('猫', '白色');console.log( cat.getName() );
作者:柏龙
链接:https://www.jianshu.com/p/d8c1c426d028
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。