码迷,mamicode.com
首页 > 其他好文 > 详细

构造函数与原型继承的使用

时间:2018-04-19 20:51:14      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:style   class   prototype   fun   原型   FN   new   ret   学习   

 
function createFn(name){
        this.name = name ;
    }
    createFn.prototype.study = function(){
        return this.name+"在学习";;
    }
    var createFn2 = new createFn("tom");
    alert(createFn2.study());//方法调用需要加括号。

 


 

构造函数与原型继承的使用

标签:style   class   prototype   fun   原型   FN   new   ret   学习   

原文地址:https://www.cnblogs.com/l8l8/p/8886131.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!